A method and system for key rotation for quantum secure networks

By employing a four-layer key structure and a state machine-driven key rotation process, combined with distributed locks and transaction mechanisms, the problems of service interruption and data consistency in traditional key management schemes are solved, achieving high availability and fault self-recovery capabilities for quantum-safe networks, making them suitable for quantum-safe networks in the financial and energy sectors.

CN122268582APending Publication Date: 2026-06-23BEIJING ZHENGDAO QUANTUM TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610458856.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-09
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

Traditional key management schemes in quantum secure networks suffer from problems such as easy service interruption, difficulty in ensuring data consistency, difficulty in fault recovery, and lack of key state management mechanisms, which have a significant impact, especially in fields with stringent real-time requirements such as financial transactions and energy scheduling.

Method used

A four-layer key structure (old key, current key, next key, and fixed key) management system is adopted, which combines a state machine-driven key rotation process, a distributed lock mechanism, and a database transaction mechanism to achieve seamless key switching and fault self-recovery. The distributed lock mechanism enables exclusive key switching in a multi-node environment, and the distributed lock and concurrency control lock are used to control concurrent requests in a coordinated manner. The system also combines log traceability and transaction mechanism to achieve automatic fault recovery.

Benefits of technology

It achieves seamless service continuity during key rotation, 100% decryption success rate, and fault self-recovery capability, improving system stability and scalability and meeting the high availability requirements of key sectors such as finance and energy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122268582A_ABST
    Figure CN122268582A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of quantum secure communication, and discloses a key rotation method and system for a quantum secure network, which executes a key rotation process in a state machine driven manner on the premise of maintaining uninterrupted business services; specifically, while a current key is kept effective to process existing business, a next key is generated; a distributed lock mechanism is used to exclusively execute a key switching operation in a multi-node environment; the next key is atomically switched to a new current key, and the original current key state is updated to an old key, so as to realize seamless transition of business data encryption and decryption keys. Compared with the prior art, the application realizes uninterrupted business during the key rotation process, establishes an effective multi-node cooperation mechanism, introduces a transaction management mechanism, designs a perfect fault detection and automatic recovery mechanism, and builds a full life cycle security management system of codebooks and random number books to realize controllable full process from creation to archiving.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of quantum secure communication technology, specifically a key rotation method and system suitable for quantum secure networks, designed for the security management and dynamic updating of key cryptography and random number books in quantum key distribution (QKD) networks. With the large-scale application of quantum secure communication technology in key areas such as financial transaction encryption, energy dispatch command transmission, and government data interaction, the long-term security and dynamic updating capability of keys have become core elements determining the continuous and stable operation of the entire quantum secure network. Background Technology

[0002] In the operational system of quantum-safe networks, the codebook and random number book are the fundamental data carriers for quantum key distribution and secure communication. The effectiveness of their key management directly affects the security and availability of the entire network. However, traditional key management schemes mostly adopt static key configuration or periodic manual updates, which have revealed many technical shortcomings in practical applications, as follows: First, the issue of service interruption is prominent. Traditional solutions require stopping the services of the cryptography book and random number book when updating keys, causing business systems to be unable to process requests normally during the update period. This interruption mode is completely unacceptable for scenarios with extremely high service continuity requirements, such as financial transactions and energy scheduling, and may directly cause economic losses or operational risks.

[0003] Secondly, data consistency is difficult to guarantee. In high-concurrency access scenarios, due to the time difference in key updates between nodes, some nodes may still be using the old key, while others have already completed the update. This inconsistency in key status will directly lead to data decryption failure and affect the normal operation of the business.

[0004] Furthermore, fault recovery is difficult. During key rotation, if the system malfunctions (such as server crashes or network interruptions), it can easily lead to problems such as key state confusion and data loss. Traditional solutions lack effective fault recovery mechanisms and often require manual intervention for troubleshooting, resulting in low recovery efficiency and high risk.

[0005] Finally, a key status management mechanism is lacking. Traditional solutions do not establish a hierarchical, status-based key lifecycle management system, making it impossible to conduct fine-grained control over the entire process of key generation, use, updating, and archiving, resulting in insufficient security and traceability of key management.

[0006] The impact of the aforementioned key rotation problem is particularly pronounced in sectors with stringent real-time requirements, such as energy and finance. For example, in energy distribution automation systems, interruptions in key rotation can lead to the failure of distribution command transmission, affecting the normal operation of power dispatch; in financial transaction systems, inconsistent key states can cause transaction data decryption failures, triggering transaction anomalies. Therefore, the industry urgently needs a key rotation method and system that can support lossless service, high availability, and fault self-recovery capabilities to address the pain points of traditional solutions. Summary of the Invention

[0007] To address the aforementioned shortcomings of existing technologies, this invention proposes a key rotation method and system for quantum secure networks.

[0008] The technical solution of this invention is implemented as follows: A key rotation method for quantum-safe networks, applied to quantum-safe networks with multiple nodes, includes a four-layer key structure, namely: The old key is only used to decrypt historical data, not to encrypt new data; The current key is used to encrypt and decrypt current business data; The next key is pre-generated and stored during the key rotation process, and is used to take effect in the next rotation cycle; A fixed key, independent of the regular key rotation process, is used to encrypt core system data and configuration parameters. The method includes: In response to a key rotation trigger event, the key rotation process is executed via a state machine-driven approach while maintaining uninterrupted business services. The key rotation process includes: While the current key remains valid to process existing business, generate the next key; Using a distributed lock mechanism, a key switching operation is performed exclusively in a multi-node environment. The distributed lock mechanism includes at least a first lock for controlling the round-robin right and a second lock for isolating business requests. The next key is atomically switched to the new current key, and the original current key state is updated to the old key, so as to achieve a seamless transition of business data encryption and decryption keys.

[0009] Preferably, the key rotation process further includes the following ordered state transition steps: In the initial state, the system is running normally, and all business data encryption and decryption are completed using the current key, without key rotation. In the rotation preparation state, in response to the rotation trigger, the first lock is acquired and the next key is generated; In the data re-encryption state, the existing data is decrypted using the current key and then re-encrypted using the next key. In service isolation mode, set the second lock to isolate new requests and process in-transit business; In the key switching state, the next key will be switched to the new current key, and the original current key will be converted to the old key; The state is cleared, all locks are released, services are restored, and a new key is generated for the next operation.

[0010] Preferably, the four-layer key is stored simultaneously in persistent storage medium and cache, and the key state in memory is automatically reconstructed by comparing the key version information in persistent storage and cache when the system starts up or recovers from a fault.

[0011] Preferably, the distributed lock mechanism is a three-level distributed lock collaborative control mechanism, including: The key rotation lock, which is the first lock, is implemented based on a distributed coordination service and is used to elect a master node among multiple nodes to ensure that only one node executes the rotation process at the same time. The service denial lock, also known as the second lock, is set by the rotating node after data re-encryption is completed. It is used to temporarily block new key-related service requests and minimize the service interruption window. The concurrency control lock is a set of configurable mutexes used to control the maximum number of concurrent requests still being processed before the denial-of-service lock takes effect, ensuring smooth business processing.

[0012] Preferably, during the period when the denial-of-service lock is in effect, non-key-related service interfaces are not affected by the denial-of-service lock and continue to provide services to the outside world, achieving zero interruption of non-key services.

[0013] Preferably, the atomic switching operation is implemented through a database transaction mechanism to ensure that the three operations of promoting the next key to the current key, downgrading the original current key to the old key, and generating a new next key are all committed or rolled back in the same database transaction, so as to ensure the consistency of the key state.

[0014] Preferably, the method further includes a fault recovery step: Logs are recorded in real time for each step of the key rotation process, along with the corresponding key version information. When the system restarts after a failure, it reads the logs and key version information to automatically determine the rotation progress before the failure. If the failure occurs before the atomic switch operation, a rollback to the initial state is triggered; if the failure occurs after the atomic switch operation, the unfinished rotation process continues to be executed.

[0015] Preferably, the method further includes lifecycle management of the codebook and / or random number book: The state of the codebook is divided into multiple stages such as creation, used, used up, in rotation, and archived. Each stage of the codebook is bound to a corresponding decryption or encryption key. The codebook in the "in rotation" state is encrypted using the next key. After the key rotation is completed, the data in the original random number book is cleared, and a new random number book is generated based on the new current key.

[0016] The present invention also provides a key rotation system for quantum-safe networks, deployed in a quantum-safe network containing multiple nodes, the system comprising: The key status management module is used to maintain multi-layered keys, including the current key, the next key, and the old key, and to manage their lifecycle. The state machine control module is used to respond to key rotation trigger events and drive the system to execute a standardized process of rotation preparation, data re-encryption, service isolation, key switching and state cleanup in sequence. The distributed lock management module is used in a multi-node environment to achieve concurrent control and lossless business isolation of the key rotation process through a distributed lock coordination mechanism that includes at least a first lock and a second lock. The atomic switching module is used to atomically switch the next key to the new current key through a database transaction, and synchronously update the status of other keys.

[0017] Preferably, the key state management module is further used to manage four layers of keys: old key, current key, next key, and fixed key; and to store the four layers of keys simultaneously in persistent storage medium and cache to achieve rapid state reconstruction after a failure. The distributed lock management module includes: The round-robin lock unit is used to implement mutual exclusion between nodes and elect a round-robin master node; Denial-of-service lock units are set by the round-robin nodes at specific stages to block new key-related requests; The concurrency control lock unit provides a configurable number of locks to control the amount of concurrent processing of requests in transit. The fault recovery module includes: The log recording unit is used to record each step of the key rotation operation and the corresponding key version; The state reconstruction unit is used to automatically reconstruct the system state based on the logs and key version information after a system failure restart, and to decide whether to continue the rotation or rollback operation.

[0018] Preferably, the system further includes a data lifecycle management module for managing the lifecycle of the codebook and / or random number book, including: Different keys are dynamically bound to the codebook for encryption and decryption operations based on the different stages of its use. After the key rotation is completed, the random number book is automatically reset and regenerated based on the new current key.

[0019] Compared with the prior art, the present invention has the following beneficial effects: Significantly improved service continuity: During key rotation, service availability reaches 99.99% through service isolation (request queuing instead of rejection) and seamless key switching mechanism, fully meeting the high requirements for service continuity in key fields such as finance and energy, and solving the pain point of easy service interruption in traditional solutions; State consistency is absolutely guaranteed: By leveraging distributed locks (avoiding concurrent rotation across multiple nodes) and database transactions (ensuring atomicity of operations), complete consistency of key states is achieved in a multi-node environment, with a 100% decryption success rate, eliminating business anomalies caused by state inconsistency. Significantly enhanced fault self-recovery capabilities: Based on real-time rotating logs and key version records, the system can automatically rebuild its state in the event of a failure, enabling the continuation or rollback of operations without manual intervention. This significantly reduces operational costs and improves system stability. Excellent system scalability: The technical solution of this invention supports both single-node and multi-node deployment. In a multi-node environment, through the master node election and state synchronization mechanism, it can be easily expanded to a large-scale cluster to meet the needs of quantum security networks of different sizes. Flexible and controllable business concurrency: Through a configurable number of concurrent control locks, the system can dynamically adjust the concurrent processing capacity of key-related services during the core rotation phase, minimizing the impact on business operations; Comprehensive security enhancement: On the one hand, regular key rotation shortens the validity period of keys and reduces the risk of keys being cracked; on the other hand, the design of fixed keys is specifically designed to protect core system-level data, avoiding the impact of regular rotation on the basic security of the system, thus forming a multi-layered security system. Attached Figure Description

[0020] Figure 1 This is an architecture diagram of the key management module of the present invention; Figure 2 This is a key rotation state transition diagram for the present invention; Figure 3 This is a flowchart of the key rotation coordination process in a high-availability environment according to the present invention; Figure 4 This is a flowchart illustrating the collaborative working mechanism of the three locks in this invention. Figure 5 This describes the processing logic of the password download service during the rotation period of this invention. Detailed Implementation

[0021] The present invention will now be clearly and completely described with reference to the accompanying drawings in the embodiments of the present invention.

[0022] A key rotation method for quantum-safe networks is proposed, applicable to quantum-safe networks with multiple nodes. To meet the key usage requirements in different scenarios, this invention adopts a four-layer key state management system, where each key has a clear division of labor and works collaboratively. Old Key: Primarily used to decrypt codebook data that has been encrypted before the key rotation, ensuring the traceability and decryptability of historical data and preventing the loss of historical data due to key updates; Current Key: As the core key for business operation, it is responsible for the encryption and decryption of all current business data and is crucial for the normal operation of the system; Next Key: Generated in advance during the key rotation process, it is used to encrypt new data during the rotation phase and prepare for subsequent key switching; Fixed Key: Specifically used for encrypting core system-level data (such as system configuration and parameter information), it is not updated with regular key rotation, ensuring the long-term security of the system's basic data.

[0023] Each layer of keys is stored in a system parameter table (persistent storage) and memory (efficient access), supporting dynamic updates and fault recovery. When a system failure occurs, the key state can be quickly restored by comparing the data in the parameter table and memory.

[0024] The method includes: In response to a key rotation trigger event, the key rotation process is executed via a state machine-driven approach while maintaining uninterrupted business services. The key rotation process includes: While the current key remains valid to process existing business, generate the next key; Using a distributed lock mechanism, a key switching operation is performed exclusively in a multi-node environment. The distributed lock mechanism includes at least a first lock for controlling the round-robin right and a second lock for isolating business requests. The next key is atomically switched to the new current key, and the original current key state is updated to the old key, so as to achieve a seamless transition of business data encryption and decryption keys.

[0025] The key rotation process further includes the following ordered state transition steps: To ensure the orderliness and controllability of the key rotation process, this invention designs a complete rotation process based on a state machine, including the following states and state transition logic: Initial state: The system is running normally, and all business data encryption and decryption are completed using the current key, with no key rotation operation. Round-robin preparation: The system first acquires a distributed lock (to prevent multiple nodes from executing the round-robin simultaneously), sets the round-robin status flag (to avoid interference from other operations), and initializes the key for the next round (to prepare for subsequent round-robins); Data re-encryption: Re-encrypt the codebook that has been put into use. The specific process is to decrypt the codebook data using the current key, and then encrypt the decrypted data using the next key. At the same time, the system status is updated to "in rotation" to facilitate monitoring by operation and maintenance personnel. Service isolation: After re-encryption is completed, the round-robin thread sets a "deny service lock". The key and random number related interfaces determine whether to reject new requests by detecting this lock. At the same time, after the round-robin thread monitors and acquires the "concurrency control lock", it continues to process the final round-robin and key switching operations of the business requests in transit. Key switching: The pre-generated next key is officially promoted to the current key, while the original current key is archived as the old key, and a new next key is regenerated to ensure the continuity of the key system; State cleanup: Clear the rotation state flags in the system, release the distributed lock, remove service isolation restrictions, allow new business requests to access, and generate a new keybook based on the new current key to complete the entire rotation process.

[0026] The distributed lock mechanism is specifically a three-level distributed lock collaborative control mechanism. To solve the problems of concurrent round-robin and service continuity in a multi-node environment, this invention proposes a three-level distributed lock collaborative control mechanism: Key rotation lock: A mutex lock implemented based on Redis, used to control the preemption of different nodes for the control of database rotation, ensuring that only one node can initiate the rotation process at the same time; Denial-of-Service Lock: Also implemented based on Redis, this lock is set by a round-robin thread after re-encrypting the existing data. Key- and random number-related interfaces check this lock upon receiving a new request; if the lock exists, service is denied (this does not affect other non-key-related interfaces). Concurrency control locks: A configurable set of mutexes based on Redis. During the phase where the key rotation lock is set but the denial-of-service lock is not, the key and random number interface can attempt to acquire these locks. If successful, request processing can continue. The number of locks can be dynamically configured, enabling flexible control over concurrency.

[0027] Through the above-mentioned three-lock synergy, the present invention achieves: The non-key and random number interfaces remain unaffected throughout the entire rotation process; The denial-of-service window for the key and random number interface is minimized; In-transit transactions can continue to be processed using concurrent control locks, ensuring business integrity.

[0028] During the period when the denial-of-service lock is in effect, non-key-related service interfaces are not affected by the denial-of-service lock and continue to provide services to the outside world, achieving zero interruption of non-key services.

[0029] The atomic switching operation is implemented through a database transaction mechanism, ensuring that the three operations of promoting the next key to the current key, downgrading the original current key to the old key, and generating a new next key are all committed or rolled back in the same database transaction, so as to guarantee the consistency of the key state.

[0030] To address system failures during key rotation, this invention designs a robust fault recovery and consistency guarantee mechanism: Real-time logging: Real-time logging of every step of the key rotation (such as key generation, status update, and data re-encryption) and synchronous recording of key version information to ensure the traceability of the entire rotation process; Database transaction mechanism: Key operations such as key switching and state updates are incorporated into database transaction management to ensure the atomicity of operations—either all operations succeed or all are rolled back, avoiding data inconsistency caused by partial success of operations; Fault recovery logic: When a system failure occurs, the system state before the failure is automatically reconstructed based on the real-time recorded rotation logs and key version information. If the failure occurs in the middle of the rotation process, the unfinished operations can continue to be executed based on the logs. If the failure causes some operations to fail, the rollback mechanism is triggered to restore the normal state before the failure.

[0031] To achieve refined management of the codebook and random number book, this invention clearly defines their lifecycle: The codebook lifecycle is divided into five stages: creation, used, used up, in rotation, and archived. Each stage is associated with a corresponding decryption / encryption key. For example, a codebook in the "used" stage is decrypted using the current key, while a codebook in the "in rotation" stage is encrypted using the next key, ensuring secure use of the codebook at different stages. Random number book lifecycle: After the key rotation is completed, the system automatically clears the data in the original random number book and regenerates the random number book based on the new current key to ensure the consistency between the random number book and the current key and avoid security risks caused by the mismatch between the random number book and the key.

[0032] like Figure 1 The present invention also provides a key rotation system for quantum-safe networks, deployed in a quantum-safe network containing multiple nodes, the system comprising: The key status management module (key generation, key update, and key storage) is used to maintain multi-layered keys, including the current key, the next key, and the old key, and to manage their lifecycle. The state machine control module (rotation state tracking, keybook status display, and fault detection) is used to respond to key rotation trigger events and drive the system to sequentially execute a standardized process of rotation preparation, data re-encryption, service isolation, key switching, and state cleanup. The distributed lock management module (Redis locks, concurrency control, timeout handling) is used in a multi-node environment to achieve concurrency control and lossless business isolation of the key rotation process through a distributed lock coordination mechanism that includes at least a first lock and a second lock. The atomic switching module, also known as the transaction management module (atomic operations, data consistency, and rollback mechanism), is used to atomically switch the next key to the new current key through database transactions and synchronously update the status of other keys. External service interfaces (passwordbook download, random number book download, status query, and key update notification); Database storage layer (password book table, random number book table, system parameter table, and archive table).

[0033] The key state management module is further used to manage four layers of keys: old key, current key, next key, and fixed key; and stores these four layers of keys simultaneously in persistent storage medium and cache to achieve rapid state reconstruction after a failure. The distributed lock management module includes: The round-robin lock unit is used to implement mutual exclusion between nodes and elect a round-robin master node; Denial-of-service lock units are set by the round-robin nodes at specific stages to block new key-related requests; The concurrency control lock unit provides a configurable number of locks to control the amount of concurrent processing of requests in transit. The fault recovery module includes: The log recording unit is used to record each step of the key rotation operation and the corresponding key version; The state reconstruction unit is used to automatically reconstruct the system state based on the logs and key version information after a system failure restart, and to decide whether to continue the rotation or rollback operation.

[0034] The system also includes a data lifecycle management module for managing the lifecycle of the codebook and / or random number book, including: Different keys are dynamically bound to the codebook for encryption and decryption operations based on the different stages of its use. After the key rotation is completed, the random number book is automatically reset and regenerated based on the new current key.

[0035] like Figure 2 The diagram illustrates the state machine-driven key rotation process, including the transition conditions and order of six states: initial state, rotation preparation, data re-encryption, service isolation, key switching, and state cleanup. This clearly demonstrates the orderly nature of the rotation process. Start Rotation: Initiate the key rotation process; Rotation preparation: Perform necessary initialization work; Acquire key for round-robin lock: Attempt to acquire a distributed lock to prevent concurrent round-robin; Determine if the acquisition was successful: If it fails, it will enter a waiting or termination state (it may wait for a retry or terminate the process directly). If successful, proceed to the next step; Set a rotation flag: Mark that the system is performing a rotation; Generate next key: Generate new key material; Data re-encryption: Re-encrypting existing data using a new key; Initiating a database transaction: Starting a transaction ensures atomicity; Key switching: Updates the system's current key to a new key; Acquire concurrent control locks to handle in-transit requests: Ensure the safety of concurrent operations by processing requests that have not yet been completed.

[0036] Service isolation: Set a denial-of-service lock: temporarily reject new requests to avoid interference; Transaction execution: Performing specific database update operations; Determine if a transaction has failed: If successful, the transaction is committed, and then the process proceeds to clear the flags in the rotation. If it fails, the transaction will be rolled back and the fault recovery process will begin (fault recovery process steps). Fault recovery process: Start fault recovery: Enter recovery process; State cleanup: Clean up abnormal states; Determine the stage at which the fault occurred: Analyze which step the fault occurred in; Read the rotation log: View the recorded progress; Determine whether it is permissible to continue: If it can continue, then proceed with the subsequent steps (which may jump to an incomplete step, such as retrying the transaction or committing directly, but the diagram does not explicitly indicate this). If it cannot continue, roll back to the initial state and restore the state before the rotation; Recovery complete: The fault recovery process has ended; Clear rotation markers: Remove rotation markers; Generate a new codebook: Produce a new codebook (which may be used later); Rotation complete: The entire process is finished.

[0037] like Figure 3 The diagram shows the key rotation coordination process in a high-availability environment. For multi-node high-availability environments, this diagram illustrates the coordination logic of key steps such as master node election, key synchronization, and state coordination, demonstrating the coordination mechanism for key rotation in a multi-node environment. Details are as follows: The interaction process between node A, node B, Redis, and the database is as follows: Node A attempts to acquire a lock from Redis; Redis sets the lock state and returns "lock state set successfully" to node A; Node A received a success response, indicating that it successfully acquired the lock; Node A begins executing the key rotation process; Node A updates the key status to the database, and the database returns "Key status update complete" after completing the update; Node A sends a "rotation complete notification" to Node B; After receiving the notification, node B forces a key update to the database. The database completes the update and returns "Key update complete". Node B sends a "confirmation of update completion" message to Node A; After receiving the confirmation, node A releases the lock to Redis; Redis clears the lock state and returns "Lock state clearing complete" to node A.

[0038] like Figure 4 The flowchart illustrates the collaborative working mechanism of the three locks: a detailed description of the states (setting / releasing) of the "key rotation lock," "denial-of-service lock," and "concurrency control lock" at each stage of the rotation and their impact on business requests. The key rotation process consists of four stages, as detailed below: Key rotation process begins: The entire key rotation process is initiated. Acquire a round-robin lock: Attempt to acquire a distributed lock to prevent concurrent round-robin. Rotary lock configured: Lock acquired successfully, system enters rotating state; Phase 1: Initialization and Encryption Initiate the codebook re-encryption operation to re-encrypt the codebook data; Determine if re-encryption is complete: If successful, a denial-of-service lock is set (subsequent key-related new requests will be rejected or queued). If not completed, continue re-encryption (the loop is not explicitly shown in the diagram, but it implies waiting for completion). Phase Two: Re-encryption Logic After setting a denial-of-service lock, new requests related to the key are rejected or queued, while non-key requests are processed normally. A rotating thread acquires the concurrency control lock to ensure concurrency safety; Processing pending requests and waiting for ongoing requests to complete; Phase Three: Execution and Cleanup Perform a key switching operation to update the system's current key to the new key; Clean up all locks (including rotation locks, denial-of-service locks, concurrency control locks, etc.); Phase Four: Completion Once the rotation is complete, the system will resume normal service.

[0039] like Figure 5 As shown, the processing logic of the keybook download service during key rotation is as follows: This diagram focuses on the special processing flow of the keybook download service during key rotation, including request interception, service queuing, key matching, and other steps, to ensure the availability and data consistency of the keybook download service during rotation.

[0040] The processing flow for password book download requests is as follows: Passwordbook download request: Start processing download request; Determine if the system is in a rotation state: If not, proceed to the normal download process (directly return to the password book, details not provided); If so, proceed to the next step and check the password book status; Codebook state branches: Re-encryption not started: Decrypt the codebook directly using the old key; Return to the codebook; Re-encryption in progress: Request to join the queue and wait for the turn to complete; Once the rotation is complete, continue processing the request; Waiting for re-encryption to complete (i.e., the rotation ends); Then determine the version of the requested passwordbook: If an older version is requested, the old key will be used for decryption; If a new version is requested, decrypt it using the new key; Return to the codebook; Re-encryption complete: Directly determine the password version requested: If an older version is requested, the old key will be used for decryption; If a new version is requested, decrypt it using the new key; Return to the codebook.

[0041] Example 1: Single-node key rotation process (energy sector) This embodiment uses a quantum-encrypted power distribution automation system in the energy sector as an application scenario. This system must ensure the real-time performance and security of power distribution command transmission, and service interruptions due to key rotation are not permitted. The specific implementation process is as follows: Rotation preparation phase: The system first attempts to acquire the key rotation lock. If the acquisition is successful (indicating that no other node is performing rotation), the "rotation in progress" status flag is set in the system parameter table, and the next key is generated based on the quantum random number generation algorithm. At the same time, the next key is stored in memory and the parameter table. Codebook re-encryption phase: The system iterates through all codebooks in the "used" state, decrypts the codebook data using the current key, and then encrypts the decrypted data using the next key. After encryption is complete, the codebook status is updated to "in rotation" and a re-encryption log is recorded. Service isolation phase: The system sets a denial-of-service lock in memory to temporarily block new power distribution command encryption requests (during the blocking period, the request enters the queue and is not directly rejected) to prevent new requests from using old keys to encrypt data; Key switching phase: Start a database transaction and perform three operations in the transaction: update the next key to the current key, archive the original current key as the old key, and regenerate the new next key. After all three operations are completed, commit the transaction and update the key state in memory synchronously. State cleanup phase: After a transaction is successfully committed, the system clears the "Rotating" status flag in the parameter table, releases the key rotation lock, removes the service rejection flag (allowing queued requests to access), and generates a new keybook based on the new current key, completing the single-node key rotation.

[0042] Example 2: Key Rotation in a High-Availability Environment (Financial Sector) This embodiment uses a quantum-encrypted trading system in the financial field as an application scenario. This system employs a multi-node cluster deployment (master-slave architecture) and must ensure the consistency and high availability of encrypted transaction data, preventing key rotation failure due to a single node malfunction. The specific implementation process is as follows: Master node election phase: All nodes simultaneously attempt to acquire the key rotation lock. The first node to acquire the lock becomes the master node, responsible for leading the key rotation. Other nodes act as slave nodes, waiting for the master node to synchronize its state. Master node rotation execution phase: The master node completes the local key rotation operation according to the process of "rotation preparation → password book re-encryption → service isolation → key switching". After each phase is completed, the current status (such as "re-encryption completed" or "key switched") is synchronized to the shared status table of the database. Key synchronization phase: The master node sends a key update notification to all slave nodes through a message queue (such as Kafka). After receiving the notification, the slave nodes read the new current key, old key and next key from the shared state table and update the local memory and parameter table synchronously. State synchronization phase: After the slave node updates its key, it sends a synchronization confirmation message to the master node. After the master node receives the confirmation messages from all slave nodes, it marks "full node synchronization complete" in the shared state table. If some slave nodes fail to confirm in time, the master node will resend the notification to ensure that all nodes are in the same state. Failover Phase: If the master node crashes during the rotation process (e.g., due to a server power outage), the slave nodes periodically check the master node's heartbeat status. Upon detecting a master node crash, the remaining nodes re-compete for the Redis distributed lock, and the node that acquires the lock becomes the new master node. The new master node determines the rotation progress before the crash by reading the rotation log and key status in the shared state table: if the crash occurred before the transaction was committed, a rollback mechanism is triggered to restore all nodes to their pre-crash state; if the crash occurred after the transaction was committed, subsequent state cleanup and slave node synchronization operations continue to ensure the rotation process is uninterrupted.

[0043] As can be seen from the various embodiments of the present invention, the present invention proposes a key rotation method and system for quantum secure networks. The present invention adopts a four-layer key state management system and innovatively proposes a four-layer key division of labor mode of "old-current-next-fixed", which covers four scenarios: historical data decryption, current business encryption, future rotation preparation, and system data protection. This solves the problem that traditional single-layer keys cannot take into account both historical data and real-time business. A standardized process driven by a state machine is adopted. The standardized rotation process is constructed through six distinct states (initial, rotation preparation, data re-encryption, service isolation, key switching, and state cleanup) to ensure the orderliness and traceability of key rotation and avoid process chaos caused by manual operation. By combining distributed locks with concurrency control, Redis distributed locks are integrated with concurrency threshold control. This solves the problem of multi-node concurrent rotation and ensures system stability during rotation through flow control, making it suitable for high-concurrency business scenarios. The design adopts a zero-impact approach for non-key services and uses a locking mechanism for fine-grained isolation to ensure that non-key and random number-related interface services are completely unaffected during key rotation, achieving truly lossless service. By combining log traceability with transaction mechanisms, and through the coordination of real-time log recording and database transactions, automatic recovery after failure and data consistency assurance are achieved, reducing manual operation and maintenance costs and improving the system's fault tolerance. By adopting a codebook state-key mapping management system, a one-to-one mapping relationship between codebook state and key is established, realizing full lifecycle security control of codebook from creation to archiving, and avoiding decryption failure due to codebook and key mismatch.

Claims

1. A key rotation method for quantum-safe networks, characterized in that, Applied to quantum-safe networks containing multiple nodes, it includes a four-layer key structure, namely: The old key is only used to decrypt historical data, not to encrypt new data; The current key is used to encrypt and decrypt current business data; The next key is pre-generated and stored during the key rotation process, and is used to take effect in the next rotation cycle; A fixed key, independent of the regular key rotation process, is used to encrypt core system data and configuration parameters. The method includes: In response to a key rotation trigger event, the key rotation process is executed via a state machine-driven approach while maintaining uninterrupted business services. The key rotation process includes: While the current key remains valid to process existing business, generate the next key; Using a distributed lock mechanism, a key switching operation is performed exclusively in a multi-node environment. The distributed lock mechanism includes at least a first lock for controlling the round-robin right and a second lock for isolating business requests. The next key is atomically switched to the new current key, and the original current key state is updated to the old key, so as to achieve a seamless transition of business data encryption and decryption keys.

2. The key rotation method for quantum-secure networks according to claim 1, characterized in that, The key rotation process further includes the following ordered state transition steps: In the initial state, the system is running normally, and all business data encryption and decryption are completed using the current key, without key rotation. In the rotation preparation state, in response to the rotation trigger, the first lock is acquired and the next key is generated; In the data re-encryption state, the existing data is decrypted using the current key and then re-encrypted using the next key. In service isolation mode, set the second lock to isolate new requests and process in-transit business; In the key switching state, the next key will be switched to the new current key, and the original current key will be converted to the old key; The state is cleared, all locks are released, services are restored, and a new key is generated for the next operation.

3. The key rotation method for quantum-secure networks according to claim 1, characterized in that, The four-layer key is stored simultaneously in persistent storage medium and cache. When the system starts up or recovers from a fault, the key state in memory is automatically reconstructed by comparing the key version information in persistent storage and cache.

4. The key rotation method for quantum-secure networks according to claim 3, characterized in that, The distributed lock mechanism is specifically a three-level distributed lock collaborative control mechanism, including: The key rotation lock, which is the first lock, is implemented based on a distributed coordination service and is used to elect a master node among multiple nodes to ensure that only one node executes the rotation process at the same time. The service denial lock, also known as the second lock, is set by the rotating node after data re-encryption is completed. It is used to temporarily block new key-related service requests and minimize the service interruption window. The concurrency control lock is a set of configurable mutexes used to control the maximum number of concurrent requests still being processed before the denial-of-service lock takes effect, ensuring smooth business processing.

5. The key rotation method for quantum-secure networks according to claim 4, characterized in that, During the period when the denial-of-service lock is in effect, non-key-related service interfaces are not affected by the denial-of-service lock and continue to provide services to the outside world, achieving zero interruption of non-key services.

6. The key rotation method for quantum-secure networks according to claim 1, characterized in that, The atomic switching operation is implemented through a database transaction mechanism, ensuring that the three operations of promoting the next key to the current key, downgrading the original current key to the old key, and generating a new next key are all committed or rolled back in the same database transaction, so as to guarantee the consistency of the key state.

7. The key rotation method for quantum-secure networks according to claim 1, characterized in that, The method also includes a fault recovery step: Logs are recorded in real time for each step of the key rotation process, along with the corresponding key version information. When the system restarts after a failure, it reads the logs and key version information to automatically determine the rotation progress before the failure. If the failure occurs before the atomic switch operation, a rollback to the initial state is triggered; if the failure occurs after the atomic switch operation, the unfinished rotation process continues to be executed.

8. The key rotation method for quantum-secure networks according to claim 1, characterized in that, The method also includes lifecycle management of the codebook and / or random number book: The state of the codebook is divided into multiple stages such as creation, used, used up, in rotation, and archived. Each stage of the codebook is bound to a corresponding decryption or encryption key. The codebook in the "in rotation" state is encrypted using the next key. After the key rotation is completed, the data in the original random number book is cleared, and a new random number book is generated based on the new current key.

9. A key rotation system for quantum-safe networks, used to implement the method as described in any one of claims 1-8, characterized in that, Deployed in a quantum-safe network comprising multiple nodes, the system includes: The key status management module is used to maintain multi-layered keys, including the current key, the next key, and the old key, and to manage their lifecycle. The state machine control module is used to respond to key rotation trigger events and drive the system to execute a standardized process of rotation preparation, data re-encryption, service isolation, key switching and state cleanup in sequence. The distributed lock management module is used in a multi-node environment to achieve concurrent control and lossless business isolation of the key rotation process through a distributed lock coordination mechanism that includes at least a first lock and a second lock. The atomic switching module is used to atomically switch the next key to the new current key through a database transaction, and synchronously update the status of other keys.

10. The key rotation system for quantum-secure networks according to claim 9, characterized in that, The key state management module is further used to manage four layers of keys: old key, current key, next key, and fixed key; and stores these four layers of keys simultaneously in persistent storage medium and cache to achieve rapid state reconstruction after a failure. The distributed lock management module includes: The round-robin lock unit is used to implement mutual exclusion between nodes and elect a round-robin master node; Denial-of-service lock units are set by the round-robin nodes at specific stages to block new key-related requests; The concurrency control lock unit provides a configurable number of locks to control the amount of concurrent processing of requests in transit. The fault recovery module includes: The log recording unit is used to record each step of the key rotation operation and the corresponding key version; The state reconstruction unit is used to automatically reconstruct the system state based on the logs and key version information after a system failure restart, and to decide whether to continue the rotation or rollback operation.

11. The key rotation system for quantum-secure networks according to claim 9, characterized in that, The system also includes a data lifecycle management module for managing the lifecycle of the codebook and / or random number book, including: Different keys are dynamically bound to the codebook for encryption and decryption operations based on the different stages of its use. After the key rotation is completed, the random number book is automatically reset and regenerated based on the new current key.