Method for protecting parameters of a network model based on multiple keys
By employing a multi-layered key protection method, calculating the upper bound of low-entropy pages at a single moment and the dynamic entropy judgment threshold, and combining device environment fingerprint binding and digital signature, the problem of plaintext data exposure of neural network model parameters on edge devices is solved, achieving precise control and security protection of plaintext data in memory.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-14
- Publication Date
- 2026-03-31
AI Technical Summary
Existing technologies lack fine-grained protection for neural network model parameters on edge devices, resulting in excessive exposure of plaintext data in memory and a lack of effective quantization monitoring and recycling mechanisms, posing a risk of model parameters being stolen.
A multi-key-based protection method is adopted. By calculating the upper bound of low-entropy pages at a single moment, the dynamic entropy judgment threshold, and the device environment fingerprint binding, combined with digital signature storage, a quantitative security benchmark and control mechanism are constructed to achieve dynamic and precise restriction and forced overwrite and reclamation of plaintext data in memory.
It effectively limits the amount of plaintext data exposed, eliminates the risk of memory residue and illegal migration, and improves the security and anti-attack capability of the network model in uncontrollable environments.
Smart Images

Figure CN121508859B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data protection technology, and more specifically to a method for protecting network model parameters based on multi-level keys. Background Technology
[0002] Neural network models have been widely deployed in edge computing applications such as smart cities, industrial automation, assisted driving, and intelligent security. To meet the demands for low-latency interaction, offline availability, and user privacy compliance, a large number of model inference tasks are migrating from cloud centers to resource-constrained terminal devices. Ensuring that these models are not illegally stolen, copied, or reverse engineered in uncontrolled environments, especially in easily accessible or disassembled outdoor terminal devices, has become a key challenge for edge AI deployment.
[0003] However, existing technologies for protecting network model parameters on edge devices have significant security flaws. The core issue lies in the excessively large exposure of plaintext data in runtime memory and the lack of fine-grained constraints. Although current solutions generally employ symmetric encryption algorithms for static encryption protection of model files in storage media, during model inference computation, to meet the data format requirements of neural network processors or central processing units, the encrypted parameters of the model must be decrypted and restored to plaintext form before being loaded into the device. In traditional deployment architectures, to ensure the continuity of model inference tasks and reduce latency caused by frequent input / output operations, the system typically decrypts the entire model file or large functional modules all at once during the initialization phase and keeps them resident in memory. This mechanism creates a persistent and complete plaintext data exposure window in memory. Once an attacker gains root privileges through software vulnerabilities or uses physical means to dump the device's runtime memory, they can easily intercept the complete model parameters. Furthermore, existing model parameter protection schemes lack quantitative monitoring and mandatory reclamation mechanisms for the amount of plaintext data in memory. Once the static decryption key is leaked or single-point protection fails, the entire model asset is at risk of being stolen. Summary of the Invention
[0004] To address the shortcomings of existing technologies, this invention proposes a network model parameter protection method based on multi-level keys, which solves the problems of excessive plaintext data exposure in runtime memory and lack of fine-grained constraints.
[0005] To achieve the above objectives, the present invention provides the following technical solution:
[0006] The upper bound of the single-moment low-entropy page that allows plaintext to reside is calculated based on the current device's prefetch window size, operating system page size, and the model's maximum layer size. The page budget balance is then determined by combining the low-entropy page count left over from the previous round.
[0007] Calculate the layer page cost based on the operating system page size and the parameter byte size of the current layer, and compare the page budget balance with the layer page cost;
[0008] If the page budget balance meets the layer page cost, the layer page cost is deducted from the page budget balance, and a one-time session key is derived by combining the device environment fingerprint and the call counter of the current layer.
[0009] Candidate physical pages are allocated based on layer page cost. The candidate physical pages are verified to have no residual information. After verification, the parameter ciphertext is decrypted using a one-time session key and written into the candidate physical page. The current low-entropy page count is also incremented.
[0010] Force overwrite and clear verification are performed on candidate physical pages after use. After clear verification, the page budget balance and the current low-entropy page count are updated, and the one-time session key is destroyed.
[0011] A digital signature is generated and stored based on the upper bound of the single-time low-entropy page, the current low-entropy page count, and the page budget balance at the current moment, and the current low-entropy page count at the end of this round is used as the benchmark for calculating the page budget balance in the next round.
[0012] Furthermore, the calculation process for the upper bound of a low-entropy page at a single moment is based on a worst-case safety boundary estimation strategy. This calculation requires the system to simultaneously satisfy the concurrent data residency needs of the currently executing layer and all subsequent layers within the scheduler's prefetch window. Therefore, the total number of concurrently processed layers is set to the prefetch window size plus one, and the largest layer size with the largest data volume among all model layers is selected as a unified calculation benchmark to cover the memory requirements of any layer. Based on this, the operating system page size minus one is introduced as a memory alignment compensation term, which can cover the memory requirements caused by misalignment of the model layer's starting address. To mitigate the extreme memory overhead caused by data crossing an additional physical page due to page boundaries, this calculation logic multiplies the maximum number of concurrent layers by the maximum possible memory usage of a single layer, adds an alignment compensation term, divides by the page size, and rounds up. This logic can determine the maximum number of plaintext data pages that can reside in memory simultaneously at any given time. This ensures that even under extreme conditions where all residing layers are at their maximum scale and the most unfavorable alignment occurs, the security boundaries defined by the system can still cover legitimate inference business needs, while strictly limiting the risk of plaintext exposure to the theoretically required minimum set.
[0013] Furthermore, random sampling is performed on the physical pages carrying encrypted data in the current memory to obtain sample pages. The byte Shannon entropy distribution of the sample pages is calculated to obtain the entropy mean and entropy standard deviation. The difference obtained by subtracting the entropy standard deviation from the entropy mean of the sample pages is set as the dynamic entropy judgment threshold. The dynamic entropy judgment threshold is used to distinguish between meaningless noise and structured information.
[0014] Compared with existing technologies, it has the following advantages:
[0015] This proposed method for protecting network model parameters based on multi-level keys effectively addresses the problems of excessive plaintext exposure and lack of fine-grained constraints caused by the full decryption of model parameters during edge device operation in existing technologies. It introduces a quantitative security benchmark by constructing a single-moment low-entropy page upper bound. The invention transforms security constraints into consumable page budget balances and establishes a control mechanism from budget-gated key release to streaming decryption and forced overwrite recycling. This achieves dynamic and precise limiting of plaintext content in memory, ensuring that the amount of plaintext exposure at any given time remains within a controllable security threshold. Furthermore, by combining device environment fingerprint binding and zero-proof mechanisms, it not only eliminates the risks of memory residue and illegal migration but also provides non-repudiable compliance audit evidence through digital signature storage, thereby significantly improving the network model's operational security and anti-attack capabilities in uncontrollable environments. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the method flow of the present invention. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] Please see Figure 1 This application provides a method for protecting network model parameters based on multi-level keys;
[0019] The method specifically includes the following steps:
[0020] By calling the operating system's memory management interface, the current device's operating system page size P is obtained. The header structure information of the encrypted model package pre-loaded into memory is parsed, and the parameter byte size of all levels in the model is extracted to form a parameter byte size set. Where i represents the i-th level, read the current inference engine scheduler's status register or context variable, obtain the prefetch window size w(t), and read the low-entropy page count left over from the end of the previous loop or during system initialization from the safety register. If this is the first startup, the low-entropy page count is initialized to 0.
[0021] Specifically, before executing the network model parameter protection method of the present invention, the system is in an initialization state or the state after the end of the previous inference loop. At this time, the device's security processor or trusted execution environment needs to establish a new security benchmark and transform this theoretical constraint into quantifiable digital resources for controlling key release in subsequent steps. The system first obtains the basic variables required for calculation from the hardware environment, encryption model package and runtime scheduler through the logic unit in the security processor or trusted execution environment. Among them, the operating system page size refers to the byte length of the smallest storage unit when the computer operating system performs memory management and mapping. The parameter byte size of each layer of the model refers to the total number of bytes of weight data contained in each independent computing layer or functional module divided into a group in the deep neural network. The prefetch window size is the number of data layers that are allowed to be read in advance and prepared for decryption in order to optimize computing performance during the model inference process. The low-entropy page count left over from the previous round refers to the number of pages carrying plaintext data that actually exist in the device memory before the execution of this budget calculation and have not yet been cleared. It should be set to 0 at the first startup. The above key control variables are stored in the protected volatile memory inside the trusted execution environment, which cannot be directly read or tampered with by the external operating system.
[0022] Traverse the parameter byte size set The element with the largest value is selected by comparing the sizes of the elements in the set and marked as the largest level size. The maximum layer size is the number of bytes occupied by the layer with the largest data volume among all structural layers of the entire neural network model;
[0023] Based on the maximum layer size The prefetch window size w(t) and the operating system page size P are used to calculate the upper bound B(t) of the low-entropy page at a single time step. The specific calculation formula is as follows:
[0024]
[0025] In the formula, B(t) is the upper bound of low-entropy pages at a single time. The upper bound of low-entropy pages at a single time refers to the maximum number of plaintext data pages allowed to reside simultaneously in memory at any given time t according to the security policy. For the rounding up operation, it should be noted that w(t)+1 is the total number of levels that the system allows to be in plaintext state at the same time. The operating system page size P minus 1 (P-1) is introduced into the formula as a compensation term to cover the worst-case overhead caused by memory alignment. In actual computer systems, the starting address of the model level may not be aligned with the physical page boundary, which will cause the data of that level to cross an extra physical page. By introducing this compensation term, it is ensured that the calculated single-time low-entropy page upper bound covers all possible memory usage situations, preventing legitimate decryption requests from being erroneously blocked due to overly tight boundary calculations. In another embodiment, if the system memory allocator can guarantee that the starting address of the model level is strictly aligned with the physical page boundary, the compensation term P-1 can be omitted. Whether to include this compensation term can be selected according to the specific memory management strategy.
[0026] In this example, the system calculates the upper bound of the low-entropy page at a single moment based on the acquired parameters, which is theoretically the maximum boundary that allows plaintext to exist.
[0027] Subtracting the current low-entropy page count of the system from the single-moment low-entropy page upper bound B(t) yields the current available page budget balance U(t) of the system. The page budget balance is the remaining physical page quota for decrypting the new data layer without triggering the single-moment low-entropy page upper bound violation, and is the only credential for determining whether to allow the release of the subkey.
[0028] It should be noted that in extreme scheduling situations, if the prefetch window suddenly shrinks, causing the calculated upper bound of the low-entropy page at a single moment, B(t), to be less than the current count of low-entropy pages, the page budget balance U(t) may be negative. In this case, the system temporarily sets the page budget balance U(t) to a negative or zero value to block key release requests in subsequent steps until the system reclaims enough low-entropy pages by performing a zeroing operation, causing the low-entropy page count to decrease, thereby restoring the page budget balance U(t) to a positive value. In addition, the page budget balance converts the upper bound of the low-entropy page at a single moment into a consumable control credential.
[0029] Random sampling is performed on the physical pages (ciphertext pages) carrying encrypted data in the current memory to obtain sample pages. The byte Shannon entropy distribution of the sample pages is calculated, and their entropy mean and standard deviation are statistically analyzed. The difference between the entropy mean and the entropy standard deviation of the sample pages is set as the dynamic entropy judgment threshold. Specifically, the entropy mean of the sample pages is the average statistical level of the disorder of byte data in the encrypted pages sampled in the current memory, and the entropy standard deviation of the sample pages is the dispersion of the entropy value of the encrypted pages sampled in the current memory relative to the average level. The dynamic entropy judgment threshold set in this way is a benchmark value determined by the system based on the ciphertext statistical characteristics in the current operating environment. This value is used to identify and exclude pages that may contain meaningful residual information in the subsequent memory allocation process. Since the encrypted data exhibits a pseudo-random distribution with high entropy values, while the unencrypted model parameters or code... Instructions typically exhibit a low-entropy value distribution with specific statistical regularities. Therefore, this threshold effectively defines the statistical boundary between meaningless noise and structured information. Any memory page with a byte entropy lower than this threshold is considered by the system to potentially contain undeletable plaintext remnants and is thus marked as unusable during secure mapping construction to prevent it from interfering with the system's accurate counting of the upper bound of low-entropy pages at a single moment. This threshold is the standard threshold for screening qualified physical pages. It should be noted that the random sampling is not a full scan, but rather adopts a preset sampling strategy. Specifically, this strategy involves randomly selecting N discrete physical pages from the current ciphertext page address space, where N is a preset positive integer (e.g., 16 to 128 pages), or selecting a set of pages that account for a preset proportion (e.g., 1%) of the total number of current ciphertext pages. This sampling quantity is designed to minimize the sample size of the calculated mean and standard deviation.
[0030] Read the parameter size in bytes of the current level j to be decrypted from the structure table of the encryption model package. The parameter size of the j-th layer in bytes The result of dividing by the operating system page size P and rounding up is marked as the layer page cost of the j-th layer. The layer page cost is the number of pages required to fully carry the plaintext data of the current layer in memory. The value of the layer page cost directly corresponds to the page budget amount that the system needs to deduct if the current layer to be decrypted is loaded into memory.
[0031] The page budget balance U(t) is compared with the layer page cost. If the page budget balance U(t) is less than the layer page cost, the system determines that the budget is insufficient, refuses to perform the key reconstruction operation, and returns a resource blocking signal to the scheduler, forcing the system to enter a waiting state until the subsequent steps complete the page reclamation and budget backfilling.
[0032] If the page budget balance U(t) is greater than or equal to the layer page cost, the system determines that the budget is sufficient, performs an atomic deduction operation, updates the page budget balance, and writes the deducted page budget balance U(t) back to the safety register. Specifically, the atomic deduction operation is to update the page budget balance U(t) by subtracting the layer page cost. Atomic deduction ensures that in a multi-tasking operating system, the page budget balance, a shared resource, will not be interfered with by other concurrent processes or threads during the modification process, thus guaranteeing the accuracy and consistency of the balance change.
[0033] It should be noted that the atomic deduction operation refers to ensuring at the hardware level that the three actions of reading, modifying, and writing back cannot be interrupted or interrupted. This is to prevent the risk of double payment or overdraft caused by multiple levels reading the same budget balance at the same time in a multi-threaded concurrent inference scenario, and to ensure the absolute rigidity of the safety upper bound B(t), ensuring that the key release operation is strictly controlled within the single-moment low-entropy page upper bound.
[0034] The system extracts the set of subkey slices in the encapsulated state corresponding to the current level j from the encryption model package. Within a trusted execution environment or security processor, the system reconstructs the slice set into the original subkey. The system collects the current device's environmental fingerprint information (Env) and the current level's call counter (Cou), and uses the hash-based message authentication code key derivation function (HKDF) in conjunction with the original subkey. Environment fingerprint information (Env) and call counter Derive the one-time session key for the current level The details are as follows:
[0035]
[0036] Specifically, the subkey slice set is a set of multiple data fragments into which the original key is divided during the model distribution stage to prevent single point of leakage. The environmental fingerprint information is a data digest that can uniquely identify the hardware characteristics of the current device and the state of the trusted execution environment, such as CPU serial number, TEE public key hash, etc. The one-time session key is a temporary symmetric key that is only valid in the current device, the current inference session, and the current level of computation. The one-time session key will be destroyed immediately after the decryption task is completed.
[0037] It should be noted that the introduction of environmental fingerprint information as the salt required for derivation is to achieve device environment binding, so that even if an attacker steals the model package and storage medium, they will not be able to derive the correct decryption key on an unauthorized device. The introduction of the call counter is to achieve forward security, ensuring that the session key generated for each inference is different, and preventing replay attacks.
[0038] The layer page cost of layer j is obtained by calling the operating system's kernel memory allocation interface to request the allocation of free pages equal to the layer page cost. This results in a set of pages with contiguous or discrete addresses, which is defined as the candidate physical page set. Where k is the k-th page, and the set of candidate physical pages. ≥ The page cost of the j-th layer, specifically, the candidate physical page set is a list of memory frames that have not yet been written with new data and have been marked as free by the operating system kernel and allocated to the current inference process;
[0039] In this embodiment, the system uses the Shannon entropy algorithm as a statistical tool to quantify the degree of data disorder on a page, specifically by traversing the candidate physical page set. For each page p, calculate the page byte Shannon entropy of each page p. The specific calculation process is as follows:
[0040]
[0041] In the formula, x is a byte value (ranging from 0 to 255). This represents the number of times the byte value x appears in page p, where P is the total number of bytes in page p, i.e., the operating system page size. The page byte Shannon entropy is a statistic that measures the degree of disorder in the data distribution within a memory page. Specifically, by applying the Shannon entropy algorithm to the security verification of runtime memory pages, a dynamic memory admission mechanism is constructed by utilizing the characteristics of low entropy for plaintext and high entropy for ciphertext, and the average information content of the byte distribution within the page is calculated.
[0042] If the page byte Shannon entropy of page p ≥ Dynamic entropy threshold, or all page content is zero (i.e. If the value is 0 and confirmed by the all-zero flag, then page p is determined to be a qualified page. A qualified page is a physical page that is recognized by the system as being in a clean state and not carrying any residual information with statistical regularity, and is therefore qualified to carry new plaintext data.
[0043] If 0 < page bytes of page p, Shannon entropy If the dynamic entropy threshold is exceeded, then page p is determined to be a low-entropy dirty page (which may contain uncleaned residual plaintext) and is removed.
[0044] It should be noted that the screening and judgment using the dynamic entropy threshold is for residual detection. In the security model of this invention, a qualified physical page used to carry newly decrypted data should initially be information-free. A page with all zeros obviously satisfies the information-free condition. Pages with entropy values greater than the dynamic entropy threshold are statistically equivalent to high-entropy noise or ciphertext, meaning they do not contain statistically regular plaintext structures, and are therefore also considered to satisfy the information-free condition (or clean state). Conversely, if the entropy value of a candidate page is lower than this threshold, it means that the page is highly likely to contain residual information. Plaintext parameters left over from the first round of reasoning that have not been completely destroyed may interfere with the audit system's accurate counting of the current low-entropy page count if the page is used directly. By forcing the initial state of the page to be high-entropy (similar to ciphertext noise) or all zero and removing pages below the threshold, it is ensured that the transition of the memory state is clear and controllable when writing plaintext in subsequent steps. It should be further noted that, as a preferred high-performance variant, if the underlying operating system supports the trusted zero-page initialization feature, the system can directly check the cleared flag of the operating system to replace the above entropy calculation, thereby reducing the computational overhead.
[0045] If the number of qualified pages is greater than or equal to the page cost of the j-th level, then select qualified pages whose number equals the page cost, establish a mapping relationship between virtual addresses and physical addresses, and construct a set of secure mapped pages. The secure mapping page set is a list of pages that have passed security verification, have established address mapping relationships, and are about to be used to write decrypted plaintext parameters. The number of elements in the set is equal to the page cost of the level to be decrypted.
[0046] If the number of qualified pages is less than the layer page cost of layer j, it indicates that there are too many dirty pages or insufficient free memory in the current memory environment. In this case, in order to prevent the page budget balance that has been atomically deducted from being wasted (causing budget leakage), the system must perform a budget rollback operation. Specifically, the updated page budget balance U(t) is added to the layer page cost of layer j to obtain the page budget balance U(t) before the update. After performing the budget rollback, the system throws a memory cleaning request exception to the scheduler, suspending the decryption process of the current layer.
[0047] It should be noted that budget rollback is an operation that returns the previously deducted page budget to the system when the decryption process is abnormally terminated. The budget rollback mechanism is a key part of this solution. In the previous steps, the budget was pre-deducted atomically under the premise that successful decryption was expected. If the mapping cannot be completed due to memory reasons, this part of the budget must be returned. Otherwise, as the running time goes by, the available page budget balance U(t) of the system will continue to decrease due to the accumulation of errors, eventually leading to service unavailability.
[0048] Locate the parameter ciphertext of the current level j in the encryption model package, logically divide the parameter ciphertext into blocks according to the operating system page size P, and generate a ciphertext block sequence. The ciphertext block sequence refers to the logical data segment queue formed by cutting a continuous encrypted binary data stream into fixed byte lengths (page size).
[0049] Establish a mapping index to associate each ciphertext block in the sequence of ciphertext blocks with a set of secure mapping pages. Each physical page in the memory corresponds one-to-one with the other, resulting in a mapping pair (ciphertext block, physical page). Specifically, the mapping index refers to the addressing table that guides direct memory access (DMA) or the CPU on how to accurately write the decrypted data to the specified physical address. One-to-one correspondence means that the ciphertext block bytes of the kth operating system page size P of the parameter ciphertext correspond to the kth physical page in memory.
[0050] The system initiates a decryption loop, using a one-time session key for each mapping pair. The ciphertext block is decrypted using the selected symmetric decryption algorithm (e.g., AES-GCM) to generate a plaintext data block. The generated plaintext data block is then directly written into the corresponding physical page. At this point, the state of the physical page transitions from high entropy or all zero to low entropy (plaintext).
[0051] After writing the plaintext data block to the physical page, the system immediately updates the global current low-entropy page count. Specifically, the current low-entropy page count L(t) is incremented by 1 to obtain the updated current low-entropy page count L(t).
[0052] Preferably, the decryption and writing operations are not completed all at once across all layers, but are performed page by page using the pipeline characteristics of the CPU or a dedicated encryption / decryption coprocessor. At the same time, the increase in the count must be completed within the same time window as the plaintext is written to disk (written to memory) to prevent a regulatory vacuum period where plaintext already exists but the count has not increased, and to ensure that the current low-entropy page count L(t) at any time can truly reflect the exposure risk in memory.
[0053] It should be noted that the current low-entropy page count L(t) is a dynamic variable representing the real-time plaintext inventory of the system, and it is used throughout the entire security protection method. The low-entropy page count inherited from the previous round... This is a static snapshot value of the dynamic variable at the beginning of each inference loop. Specifically, in the initial stage, the system reads the current value of L(t) and assigns it to... This serves as the deduction benchmark for calculating the current page budget balance U(t). Each time the system writes a page of plaintext data, L(t) increments by 1 in real time. At this point, the value of L(t) begins to exceed [a certain value]. The difference between the two represents the number of plaintext pages added in this round of the loop. The two overlap at the beginning of each round of the loop, then separate during the execution process, and establish a new association again at the beginning of the next round of the loop through a snapshot operation.
[0054] Once all or part of the plaintext data pages required by the current level j have been written (when pipelined computation is supported), the system sends a ready signal to the neural network inference engine (NPU or CPU computing unit). The inference engine accesses the plaintext parameters in the physical pages through virtual addresses, performs neural network operations such as matrix multiplication or convolution, and marks these physical pages that carry plaintext parameters and have been used as used plaintext pages, forming a set of used plaintext pages.
[0055] It should be noted that in order to maximize the satisfaction of the upper bound of low-entropy pages at a single moment, the inference engine should adopt a computation-discard strategy. That is, once a page of data has completed the computation, the system should be notified immediately to enter the recycling process, rather than waiting until the computation of the entire layer is completed.
[0056] Specifically, the ready signal is a hardware interrupt or software event flag used to notify the computing core that the data is ready to be read. The used plaintext page set refers to the list of pages that have been written with plaintext data and are being or have already been read by the computing unit. The used plaintext page set is the object that needs to be cleaned in the next step.
[0057] Iterate through each physical page in the set of used plaintext pages, and write all zero data or high-entropy pseudo-random noise into the entire address space of each physical page in the set of used plaintext pages to obtain the overwritten physical pages.
[0058] Preferably, after the overwrite operation, the system executes a memory barrier instruction (such as mfence under x86 architecture or DMB under ARM architecture) to force the CPU to immediately flush the dirty data in the cache to the main memory (DRAM). It should be noted that the memory barrier is executed to prevent the CPU's out-of-order execution optimization or write cache strategy from causing the zeroing operation to be delayed. Only by ensuring that the charge state on the medium has been flipped can cold start attacks or reading based on hardware probes be effectively resisted.
[0059] For each overwritten physical page, first calculate the actual hash digest value Hash(p) of the overwritten physical page. Then, compare the actual hash digest value Hash(p) with the system's preset standard hash constant. The standard hash constant is the result of performing the same hash operation on a standard page whose content is all zero and whose size is equal to the operating system page size. If the two values are equal, it proves that the overwritten physical page has been completely cleared. At this time, the overwritten physical page is marked as a reclaimed page. If the two values are not equal, it proves that there is still non-zero data remaining in the overwritten physical page, triggering a memory cleaning failure exception, refusing to refill the budget, and possibly triggering a defensive shutdown of the system.
[0060] Preferably, the page byte Shannon entropy of the overwritten physical page is calculated. If it is confirmed that the physical page is equal to 0 (when filled with all zeros) or greater than the dynamic entropy judgment threshold (when filled randomly), the overwritten physical page can also be marked as a recycled page.
[0061] It should be noted that this step constitutes the core of the proof, effectively preventing malicious or flawed upper-layer applications from deceiving the security system to obtain new budgets without actually clearing the data. Only pages whose state meets the no-information standard can be considered as having their security resources released.
[0062] Count the number of reclaimed pages, and update the page budget balance U(t) and the current low-entropy page count L(t) based on the number of reclaimed pages, as follows:
[0063] The page budget balance U(t) is increased by adding the number of pages that have been recycled to obtain the page budget balance U(t) after the update. Specifically, updating the page budget balance U(t) in this step restores the page budget quota of the system, enabling the system to process the next model level. This update step is a budget backfilling process, which is the process of returning the page budget quota that was temporarily frozen or deducted due to the decryption operation to the system after confirming that the risk has been eliminated.
[0064] Subtracting the number of reclaimed pages from the current low-entropy page count L(t) yields the reduced low-entropy page count L(t). Specifically, the updated low-entropy page count L(t) in this step accurately reflects the current low-risk state.
[0065] At the same time, the one-time session key associated with the recycled page is immediately erased from secure memory to ensure that even if there is any remaining encrypted data, it cannot be decrypted again.
[0066] Specifically, this step realizes the reverse flow of the conservation formula L(t) + U(t) ≤ B(t). The budget backfilling must lag behind the proof of nullification. This mechanism of proof before update is the key step for the self-regulation of this invention. This step aims to perform thorough memory cleaning and recover the security budget based on the cleaning results. The system requires that every page of memory that has ever carried plaintext must be forcibly overwritten and cryptographically verified. Only after proving that it has returned to a state without information is the system allowed to release the corresponding security count and restore the page budget, thereby maintaining the continuous operation capability of the system.
[0067] Read the current moment's single-moment low-entropy page upper bound B(t), current low-entropy page count L(t), and page budget balance U(t) from the security register. Obtain the current timestamp, model unique identifier, and device unique identifier. Concatenate all the above data fields in order and calculate their SHA-256 digest value. Inside the trusted execution ring, use the preset device private key to perform asymmetric encryption signature on the digest value to generate a compliance certificate. Specifically, the compliance certificate is an encrypted data block obtained by digitally signing the result of hashing the concatenated data of the single-moment low-entropy page upper bound, current low-entropy page count, page budget balance, model identifier, device identifier, and timestamp using the device private key. It is used to prove that the memory state of the system at a specific moment complies with the security policy. The device private key is an asymmetric encryption private key that is burned into the security chip at the factory and cannot be read externally. It is used to represent the unique digital identity of the device.
[0068] It should be noted that the system synchronizes the upper bound of the low-entropy page B(t) at a single moment with the current low-entropy page count L(t) under security constraints. The relationship of L(t)≤B(t) at any moment becomes permanently solidified evidence. If the audit log shows that L(t) is greater than B(t) in a certain record, or the signature cannot be verified by the device's public key, it can be determined that the device is in violation or has been attacked.
[0069] The system constructs a structured audit log entry, which contains plaintext metadata {B(t), L(t), U(t), timestamp, model unique identifier, device unique identifier} and encrypted compliance credentials. This audit log entry is appended to a local protected storage partition (e.g., a tamper-proof log area). When network bandwidth allows or a predetermined period arrives, the system reports the logs in batches to the cloud key management service through an encrypted channel. The audit log entry is the basic unit that constitutes a complete model usage behavior tracking chain.
[0070] Check the model structure table to determine if the current level is the last level of the model. If it is the last level, the process ends, the system performs the final resource release, and returns a completion signal to the application layer. If it is not the last level, the system increments the level index until it is determined whether the current level is the last level of the model.
[0071] After the process ends, the current low-entropy page count L(t) is assigned to the low-entropy page count, which is the input parameter required for the next round of the process. The system then jumps back to step 1 and starts a new round of security assessment and calculation for level i+1.
[0072] It's important to note that the handover process is crucial for ensuring the continuity of the L(t) curve. Although each iteration recalculates the upper bound B(t) of the low-entropy page at a single moment (because the prefetch window may change), the existing plaintext pages are an objective fact and must be losslessly transferred from the previous iteration to the next, serving as a deduction item when calculating the budget in the next iteration. This ensures that cross-level safety constraints always hold. Furthermore, L(t) is not reset to zero during the handover; instead, the final L(t) of the current iteration is assigned the value of the next iteration's value. This means that if there are still uncleaned pages in memory at the end of this round (e.g., data from the next level has been prefetched), these pages will be correctly counted into the next round to prevent the over-release of keys in the next round.
[0073] Specifically, this step constructs a full-dimensional security audit chain and manages the lifecycle of tasks. The system uses the device's unique identity key to solidify the compliance facts that meet the single-moment low-entropy page upper bound at the current moment into an immutable digital credential. Then, according to the model structure diagram, the task pointer is advanced to pass the current security state of the system to the next round of calculation.
[0074] The above embodiments are only used to illustrate the technical methods of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical methods of the present invention without departing from the spirit and scope of the technical methods of the present invention.
Claims
1. A method for protecting parameters of a network model based on multi-layer keys, characterized in that, The method comprises the following steps: Calculating the upper limit of the low-entropy page at a single time point based on the current device's prefetch window size, operating system page size and maximum layer size, and combining the low-entropy page count left over from the last round to determine the page budget balance; Extracting the parameter byte size of all layers in the model, and selecting the largest parameter byte size as the maximum layer size, which is the total number of bytes occupied by the layer with the largest data volume in the model; Adding one to the prefetch window size to obtain the total number of layers allowed to be concurrent, subtracting one from the operating system page size and adding the maximum layer size to obtain the maximum memory overhead of a single layer, dividing the product of the total number of layers and the maximum memory overhead of a single layer by the operating system page size, and performing an upward rounding operation on the quotient to obtain the upper limit of the low-entropy page at a single time point, wherein the prefetch window size is the number of data layers allowed to be read in advance in addition to the current calculation layer, and the upper limit of the low-entropy page at a single time point is the maximum number of plaintext data pages allowed to be simultaneously resident in the memory at any time; Calculating the layer page cost based on the operating system page size and the parameter byte size of the current layer, and comparing the page budget balance and the layer page cost; If the page budget balance meets the layer page cost, subtracting the layer page cost from the page budget balance, and deriving a one-time session key based on the device environment fingerprint and the call counter of the current layer; According to the layer page cost, allocate candidate physical pages, perform no-information residue verification on the candidate physical pages, write the parameter ciphertext into the candidate physical pages after decrypting the parameter ciphertext by the one-time session key, and increase the current low-entropy page count; Performing forced overwrite and clearing verification on the candidate physical pages after use, updating the page budget balance and the current low-entropy page count after clearing verification, and destroying the one-time session key; Generating a digital signature based on the upper limit of the low-entropy page at a single time point, the current low-entropy page count and the page budget balance at the current time, and taking the current low-entropy page count at the end of this round as the basis for calculating the page budget balance in the next round. 2.The multi-layer key-based network model parameter protection method of claim 1, wherein, The method comprises the following steps: Subtracting the low-entropy page count left over from the last round from the upper limit of the low-entropy page at a single time point to obtain the page budget balance, which is the number of pages available for decrypting new data layers; The low-entropy page count left over from the last round is the number of pages in the device memory that have not been cleared and carry plaintext data before the current calculation is performed. 3.The multi-layer key-based network model parameter protection method of claim 1, wherein, The method comprises the following steps: Obtaining the parameter byte size of the current layer, which is the current layer to be decrypted; Dividing the parameter byte size of the current layer by the operating system page size to obtain the quotient, and rounding up the quotient to determine the layer page cost, which is the number of physical pages occupied by the plaintext data carrying the current layer in the memory.
4. The multi-layer key-based network model parameter protection method of claim 3, wherein, The method comprises the following steps: Comparing the page budget balance with the layer page cost, if the page budget balance is greater than or equal to the layer page cost, updating the result of subtracting the layer page cost from the page budget balance as the new page budget balance, and writing the new page budget balance into the secure register; Extracting the sub-key slice set corresponding to the current layer and reconstructing it into the original sub-key, collecting the device environment fingerprint of the current device and the call counter of the current layer; The hash-based message authentication code key derivation function is used to operate on the original sub-key by taking the spliced data of the device environment fingerprint and the call counter as a salt value, to derive a one-time session key, which is a temporary symmetric key valid only in the current device, current inference session and current hierarchical calculation process.
5. The multi-layer key-based network model parameter protection method of claim 4, wherein, Comprise: Allocate physical free pages with a number greater than or equal to the layer page cost as candidate physical pages; The specific process of no-information residual verification on the candidate physical pages is as follows: Calculate the page byte Shannon entropy of each candidate physical page, if the page byte Shannon entropy is greater than or equal to the dynamic entropy judgment threshold or the content of the candidate physical page is all zero, it is judged that the candidate physical page passes the verification, and the candidate physical page that passes the verification is marked as a qualified page; If the number of qualified pages is greater than or equal to the layer page cost of the current layer, select the qualified pages with a number equal to the layer page cost, and construct a secure mapping page set by establishing a mapping relationship between the virtual address and the physical address; The parameter ciphertext of the current hierarchical level is logically divided into ciphertext blocks according to the operating system page size to generate a ciphertext block sequence, and a mapping index between the ciphertext blocks and the physical pages in the secure mapping page set is established to obtain a mapping pair; Each ciphertext block of the mapping pair is decrypted by a symmetric decryption algorithm to generate a plaintext data block, and the plaintext data block is written into the corresponding physical page; After each plaintext data block is written into the physical page, the current low-entropy page count is increased by 1, and the current low-entropy page count is a variable of the total number of pages actually carrying plaintext data in the memory at the current time.
6. The multi-layer key-based network model parameter protection method of claim 5, wherein, The byte Shannon entropy distribution of the sampling page is calculated, and the difference between the entropy mean and the entropy standard deviation of the sampling page is set as the dynamic entropy judgment threshold, which is a threshold for distinguishing meaningless noise from structured information.
7. The multi-layer key-based network model parameter protection method of claim 5, wherein, Comprise: Perform a physical overwrite operation on all address spaces of the candidate physical pages after use, write all-zero data, and execute a memory barrier instruction to refresh the physical main memory to obtain overwritten physical pages, wherein the candidate physical pages after use are candidate physical pages that are marked as qualified pages and have completed the model inference calculation task after being written with plaintext data blocks; Calculate the actual hash digest value of each overwritten physical page, and compare the actual hash digest value with the pre-set all-zero page hash constant. If the comparison result is consistent, it is determined that the clearing verification passes, the overwritten physical page that passes the clearing verification is marked as a recycled page, and the number of recycled pages is counted.
8. The multi-layer key-based network model parameter protection method of claim 7, wherein, Also comprise: Update the page budget balance and the current low-entropy page count based on the number of recycled pages, specifically as follows: Add the number of recycled pages to the page budget balance to obtain the refilled page budget balance, and subtract the number of recycled pages from the current low-entropy page count to obtain the reduced current low-entropy page count; At the same time, erase the one-time session key associated with the recycled page from the secure memory.
9. The multi-layer key-based network model parameter protection method of claim 8, wherein, Comprise: Read the single-time low-entropy page upper bound, the current low-entropy page count and the page budget balance of the current time from the secure register, and obtain the current timestamp, the model unique identifier and the device unique identifier; Splice all the read data fields in the predetermined order, calculate the SHA-256 digest value of the spliced data, and use the preset device private key to perform asymmetric encryption signature on the digest value in the trusted execution environment to generate a compliance credential; Build the plaintext metadata containing all the data fields and the compliance credential into an audit log entry, write the audit log entry to the local protected storage partition, and report it asynchronously through the encrypted channel; At the end of the current level of processing flow, the current low-entropy page count at this time is directly assigned to the input parameter required for the next round of process, as the last round of low-entropy page count left over when calculating the page budget balance in the next round.
Citation Information
Patent Citations
Neural network model encryption method and system for hierarchical encryption
CN120337266A
Model weight parameter protection method, terminal equipment and storage medium
CN121212349A