File processing method, computer readable storage medium and electronic device

By constructing a random file header structure to disrupt and encrypt the AI ​​model, the problem of high computational cost in encryption and decryption in existing technologies is solved, thus improving security and computational efficiency.

CN115455370BActive Publication Date: 2026-07-07FUZHOU ROCKCHIP SEMICON

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
FUZHOU ROCKCHIP SEMICON
Filing Date
2022-08-22
Publication Date
2026-07-07

AI Technical Summary

Technical Problem

Existing technologies that fully encrypt AI models result in a large amount of encryption and decryption computation, which is particularly unfavorable for deployment and implementation on end devices with limited computing resources.

Method used

By constructing a random file header structure, the source file is randomly corrupted and encrypted to form the file header structure, thus avoiding the need to encrypt the entire file and reducing the computational resource requirements.

Benefits of technology

It improves the confidentiality and security of source files while reducing the demand for computing resources, especially improving the speed of inference-before-deciphering protection on resource-constrained end devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115455370B_ABST
    Figure CN115455370B_ABST
Patent Text Reader

Abstract

The application provides a file processing method, a computer readable storage medium and an electronic device. The method comprises: creating an empty first protection file for a source file; constructing a file header structure associated with the source file based on a random number of superposition operations and operation types on the source file; encrypting the file header structure and forming a second protection file based on the encrypted file header structure and the first protection file; processing the source file according to the file header structure and forming a third protection file based on the processed source file and the second protection file. The application does not encrypt the entire source file, thereby reducing the demand for computing resources while protecting the source file. In particular, for an end device deployed in a computing resource-limited environment, the speed of source file protection before inference is improved. The method of the application is suitable for protecting AI models and various application documents, and does not limit the software and hardware environment and scene, and is highly versatile.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence (AI) technology, and in particular to the field of AI model file processing technology. Background Technology

[0002] In the field of AI, once an AI model is built and trained, it can be deployed and released. Without protection, any third party who obtains the model can analyze it using model visualization tools (such as Netron), and even run and use it directly. To protect their AI algorithm models from unauthorized use, current technology uses encryption algorithms to encrypt the entire AI model before deployment and release, and then decrypts it before inference to obtain the original model for inference. However, encrypting the entire AI model becomes computationally intensive when the model is large, especially on edge devices where computing power is limited, hindering the deployment and implementation of AI models on edge devices. Summary of the Invention

[0003] The purpose of this application is to provide a file processing method, a computer-readable storage medium, and an electronic device that can solve the technical problem of large encryption and decryption computation caused by encrypting the entire file when protecting files in the prior art.

[0004] To achieve the above and other related objectives, this application provides a file processing method. The method includes: creating an empty first protected file for a source file; constructing a file header structure associated with the source file based on a random number of superposition operations performed on the source file and the operation type, encrypting the file header structure, and forming a second protected file based on the encrypted file header structure and the first protected file; processing the source file according to the file header structure, and forming a third protected file based on the processed source file and the second protected file.

[0005] In one embodiment of this application, the file header structure consists of a base header of a preset size and a list of overlay operation units; the base header consists of a preset protection magic number, overlay mode, overlay point offset address list, overlay point offset address list length, actual overlay count, and overlay operation unit length; the overlay operation unit list is located after the base header of the preset size and is a list consisting of the number of overlay counts and overlay operation units; wherein the overlay operation unit consists of the iteration offset address list length, the iteration offset address list, the iteration operation type, an iteration operation type one-head structure, an iteration operation type two-head structure, and an iteration operation type three-head structure.

[0006] In one embodiment of this application, the step of constructing a file header structure associated with the source file based on a random number of superposition operations and operation types includes: constructing a basic header and a list of superposition operation units, and performing a random number of superposition operations on the source file based on the list of superposition operation units; in each superposition operation, constructing a corresponding file header structure according to different randomly generated operation types.

[0007] In one embodiment of this application, the operation type is an iterative operation type header structure, which consists of the actual number of operation areas and an operation area list; wherein each operation area in the operation area list consists of an offset address, a target offset address, and an operation length; the method of constructing the corresponding file header structure includes: randomly generating a first set of random numbers and a second set of random numbers, wherein the first set of random numbers corresponds to the offset address of the operation area in the source file, and the second set of random numbers corresponds to the target offset address of the operation area in the source file; inserting a third set of random numbers as the operation length after the offset address of each operation area, wherein the starting position of the third set of random numbers is determined by the target offset address of the operation area.

[0008] In one embodiment of this application, the operation type is an iterative operation type binary structure, which consists of a swap type, a swap operation mode, a pairing mode, a swap region length, an actual number of pairs, an odd swap offset address list, an even swap offset address list, an odd pairing region list, and an even pairing region list. The method of constructing the corresponding file header structure includes: generating a set of preset number of random numbers as a swap offset address list; pairing according to preset rules based on the generated random numbers, dividing the swap offset addresses in the swap offset address list into multiple pairing regions, each pairing region consisting of two swap addresses.

[0009] In one embodiment of this application, the operation type is an iterative operation type three-head structure, which consists of a grouping mode, an operation point offset address list, an actual number of groups, a group length type, and an operation group list; the method of constructing the corresponding file header structure includes: generating a set of preset number of random numbers; grouping the source files according to preset rules based on the generated random numbers, and randomly determining the group type for each group of source files; and constructing the file header structure corresponding to each group based on the group type of each group.

[0010] In one embodiment of this application, the method of encrypting the file header structure and forming a second protected file based on the encrypted file header structure and the first protected file includes: when the size of the encrypted base header is equal to the size of the unencrypted base header, and the size of the encrypted overlay operation unit list is equal to the size of the unencrypted overlay operation unit list, the encrypted base header is written into the header of the empty protected file, and the encrypted overlay operation unit list is written into the current tail of the empty protected file; when the size of the encrypted base header is not equal to the size of the unencrypted base header, or the size of the encrypted overlay operation unit list is not equal to the size of the unencrypted overlay operation unit list, an auxiliary header of a preset size is constructed, and then the auxiliary header is written into the header of the empty protected file, and the encrypted base header is written into the current tail of the empty protected file, wherein the auxiliary header includes a preset magic number, the size of the encrypted base header, and the size of the encrypted overlay operation unit list.

[0011] In one embodiment of this application, forming a second protected file based on the encrypted file header structure and the first protected file includes: writing the encrypted file header structure into the header of the first protected file to form the second protected file.

[0012] In one embodiment of this application, forming a third protection file based on the processed source file and the second protection file includes: writing the processed source file to the end of the second protection file to form the third protection file.

[0013] To achieve the above and other related objectives, this application also provides a file processing method. The method includes: verifying the first information of the protected file based on a preset file header structure, wherein the file header structure is constructed based on a random number of superposition operations on the source file and the operation type; and, in response to the first information of the protected file passing the verification, deriving the source file based on the second information of the protected file.

[0014] To achieve the above and other related objectives, this application also provides a computer-readable storage medium having computer-readable program instructions stored thereon, which, when executed, implement the file processing method described above.

[0015] To achieve the above and other related objectives, this application also provides an electronic device, including: a memory configured to store program instructions; and a processor configured to execute the program instructions to implement the file processing method.

[0016] As described above, according to the embodiments of this disclosure, the solution of this application does not encrypt the entire source file (e.g., AI model). Instead, it randomly corrupts the source file by constructing a file header structure and encrypts the random corruption rules before writing them into the source file header. Because the source file is randomly corrupted, the corrupted content is different each time for the same source file, resulting in different protected files after corruption. This maximizes the confidentiality and security of the source file protection. Simultaneously, since the entire source file is not encrypted, the demand for computing resources is reduced while protecting the source file, especially for devices with limited computing resources, thus improving the speed of deprotection before inference. The method of this application is applicable to protecting AI models and various application documents, without limitations on software and hardware environments and scenarios, and has strong versatility. Attached Figure Description

[0017] Figure 1 The diagram shown is a flowchart of a document processing method according to an embodiment of this application.

[0018] Figure 2 The diagram shown is another flowchart of a document processing method according to an embodiment of this application;

[0019] Figure 3 The flowchart shown is a document processing method according to an embodiment of this application, in which the first information of a protected document is verified.

[0020] Figure 4 The flowchart shown is a document processing method according to an embodiment of this application, in which the source file is derived based on the second information of the protected file.

[0021] Figure 5 The flowchart shown is an application example of a file processing method according to an embodiment of this application.

[0022] Figure 6 The diagram shown is a schematic diagram of the principle structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0023] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that, unless otherwise specified, the following embodiments and features described therein can be combined with each other.

[0024] In existing technologies, the entire AI model is encrypted before deployment and release, and then decrypted before inference to obtain the original model for inference. However, encrypting the entire AI model can be computationally intensive, which is detrimental to the deployment and implementation of AI models on edge devices.

[0025] To address at least the aforementioned issues, this disclosure provides a file processing scheme that eliminates the need to encrypt the entire source file. Instead, it constructs a file header structure associated with the source file based on a random number of superposition operations and the operation type. This random destruction of the source file is then performed, and the random destruction rules are encrypted and written into the source file header. This solves the technical problem of high encryption and decryption computational load caused by encrypting the entire file when protecting files in the prior art.

[0026] Hereinafter, specific embodiments of the present disclosure will be described with reference to the accompanying drawings through exemplary embodiments.

[0027] Figure 1 This is a flowchart illustrating a file processing method according to an embodiment of the present disclosure. Figure 1 As shown, the file processing method includes the following steps S110 to S140.

[0028] In step S110, an empty first protected file is created for the source file. In some embodiments, the source file is an AI model file. In other embodiments, the source file is various application documents.

[0029] In some embodiments, the file extension of the empty protected file is the same as that of the source file. In some embodiments, an empty AI protected model file, such as protected_model.pb, is created, and its file extension must be consistent with that of the AI ​​source file, such as .pb or .onnx.

[0030] In addition, in some embodiments, the file processing method may also include determining the size of the source file in preparation for the implementation of subsequent steps S120 to S140.

[0031] In step S120, a file header structure associated with the source file is constructed based on the random number of superposition operations performed on the source file and the operation type. In some embodiments, the file header structure consists of a base header of a preset size and a list of superposition operation units. The base header consists of a preset protection magic number, a superposition mode, a list of superposition point offset addresses, a list of superposition point offset addresses, a length of the list of superposition point offset addresses, the actual number of superpositions, and a length of the superposition operation unit. The list of superposition operation units is located after the base header of the preset size and consists of a list of superposition operation units consisting of the number of superpositions. The superposition operation unit consists of an iteration offset address list length, an iteration offset address list, an iteration operation type, an iteration operation type one-head structure, an iteration operation type two-head structure, and an iteration operation type three-head structure.

[0032] In step S130, the file header structure is encrypted, and a second protected file is formed based on the encrypted file header structure and the first protected file. In some embodiments, the encrypted file header structure is written into the header of the first protected file to form the second protected file.

[0033] In step S140, the source file is processed according to the file header structure, and a third protected file is formed based on the processed source file and the second protected file. In some embodiments, the processed source file is written to the end of the second protected file to form the third protected file.

[0034] The file processing method according to embodiments of this disclosure does not encrypt the entire source file (e.g., an AI model). Instead, it randomly corrupts the source file by constructing a file header structure and encrypts the random corruption rules before writing them into the source file header. Because the source file is randomly corrupted, the corrupted content is different each time for the same source file, resulting in different protected files, thus maximizing the confidentiality and security of the source file protection. Furthermore, since the entire source file is not encrypted, the demand for computing resources is reduced while protecting the source file.

[0035] The following section will describe in detail how the file header structure is constructed.

[0036] In some embodiments, constructing a file header structure associated with the source file based on a random number of superposition operations and the operation type includes: constructing a basic header and a list of superposition operation units, and performing a random number of superposition operations on the source file based on the list of superposition operation units; in each superposition operation, constructing a corresponding file header structure according to different randomly generated operation types.

[0037] In this embodiment, the file header structure consists of a base header of a preset size and a list of overlay operation units. The base header comprises a preset protection magic number, an overlay mode (e.g., overlay_mode), an overlay point offset address list (e.g., overlay_offset), the length of the overlay point offset address list (e.g., overlay_offset_len), the actual number of overlays (e.g., iteration_number), and the length of the overlay operation unit (e.g., iteration_unit_size).

[0038] The list of stacking operation units, located after a base header of a preset size, is a list consisting of stacking operation units of stacking count (e.g., iteration_number). Each stacking operation unit is composed of the length of the iteration offset address list (e.g., iteration_offset_len), the iteration offset address list (e.g., iteration_offset), the iteration operation type (e.g., iteration_op_type), a one-head structure for the iteration operation type, a two-head structure for the iteration operation type, and a three-head structure for the iteration operation type.

[0039] The iterative operation type's structure consists of the number of actual operation areas (e.g., gap_num) and a list of operation areas. Each operation area in the list consists of an offset address, a target offset address, and an operation length.

[0040] The iterative operation type binary structure consists of the swap type (e.g., swap_type), swap operation mode (e.g., swap_op_mode), pairing mode (e.g., swap_match_mode), swap region length (e.g., swap_len), actual number of pairs (e.g., match_number), a list of odd swap offset addresses, a list of even swap offset addresses, a list of odd pairing regions, and a list of even pairing regions. Each pairing region element in the odd and even pairing region lists consists of swap address one and swap address two.

[0041] The three-head structure of an iterative operation type consists of a grouping mode (e.g., group_divide_mode), a list of operation point offset addresses (e.g., op_offset), the actual number of groups (e.g., group_number), the group length type (e.g., group_len_type), and a list of operation groups.

[0042] Each operation group element in the operation group list consists of the group length (e.g., group_len), the group offset address list (e.g., group_offset), the head and tail node mode (e.g., group_head_tail_mode), the head node offset address of the group (e.g., group_head_offset), the tail node offset address of the group (e.g., group_tail_offset), the group type (e.g., group_type), a one-head structure of the group type, and a two-head structure of the group type.

[0043] The group type has the same one-head structure as the iteration operation type, and the group type has the same two-head structure as the iteration operation type.

[0044] Specifically, in this embodiment, the source file is subjected to a random number of operations (i.e., "actual stacking number of times"). For each operation, the method of constructing the corresponding file header structure is determined according to the different randomly generated operation types (i.e., "iteration operation type").

[0045] Each operation is represented by a "stacked operation unit", and the size of the "stacked operation unit" is represented by the "stacked operation unit length". All operations constitute a "stacked operation unit list".

[0046] In this embodiment, when the operation type is an iterative operation type header structure, the method of constructing the corresponding file header structure includes: randomly generating a first set of random numbers and a second set of random numbers, wherein the first set of random numbers corresponds to the offset address of the operation area in the source file, and the second set of random numbers corresponds to the target offset address of the operation area in the source file; inserting a third set of random numbers as the operation length after the offset address of each operation area, wherein the starting position of the third set of random numbers is determined by the target offset address of the operation area.

[0047] In this embodiment, when the operation type is an iterative operation type two-head structure, the method of constructing the corresponding file header structure includes: generating a set of preset number of random numbers as a list of swap offset addresses; pairing the generated random numbers according to preset rules, dividing the swap offset addresses in the list of swap offset addresses into multiple pairing areas, each pairing area consisting of two swap addresses.

[0048] In this embodiment, when the operation type is an iterative operation type three-head structure, the method of constructing the corresponding file header structure includes: generating a set of preset number of random numbers; grouping the source files according to preset rules based on the generated random numbers, and randomly determining the group type for each group of source files; and constructing the corresponding file header structure for each group based on the group type of each group.

[0049] Each operation can employ two methods (i.e., "overlay mode"). Method one ("overlay mode one") uses randomly generated random numbers (i.e., the "iterative offset address list") for each operation, and the number of random numbers generated each time (i.e., the "iterative offset address list length") is also different. Method two ("overlay mode two") uses the same set of basic random numbers (i.e., the "overlay point offset address list," the length of which is determined by the "overlay point offset address list length"), but for each operation, these basic random numbers are randomly transformed according to preset rules, and the transformed value is used as the value in the "iterative offset address list."

[0050] The "overlay point offset address list" and "overlay point offset address list length" are only used in operation method two (i.e. "overlay mode two"), and are not needed in overlay mode one.

[0051] In this embodiment, the process of constructing the file header structure is as follows:

[0052] (1) Set the protection magic number of the basic header in the file header structure to the preset magic number.

[0053] (2) Randomly generate a positive integer that is greater than or equal to a preset minimum value and less than or equal to a preset maximum value. Use the resulting random positive integer that meets the requirements as the actual number of times the basic header is stacked in the file header structure (e.g., iteration_number).

[0054] (3) Set the stacking operation unit length (e.g., iteration_unit_size) of the basic header in the file header structure to the size of the stacking operation unit.

[0055] (4) Randomly generate a positive integer, perform a modulo operation between the integer and 2, and use the resulting value as the overlay mode (e.g., overlay_mode) of the basic header in the file header structure, where 0 represents overlay mode one and 1 represents overlay mode two.

[0056] (5) Construct a list of stacking operation units consisting of the actual number of stacking times (e.g., iteration_number), which is called the stacking operation unit list.

[0057] (6) If the overlay mode (e.g., overlay_mode) is overlay mode one:

[0058] (6-1) Set the initial value of the extension length (e.g., extend_len) to 0.

[0059] (6-2) Traverse the list of stacking operation units, starting from the first element of the list (iterate_index = 0) and continuing until the actual stacking count (iteration_number) of the base header in the file header structure. For each stacking operation unit:

[0060] (6-2-1) Randomly generate a positive integer that is greater than or equal to a preset minimum value and less than or equal to a preset maximum value. Use the obtained random positive integer that meets the requirements as the length of the iterative offset address list of the superposition operation unit (e.g., iteration_offset_len).

[0061] (6-2-2) Generate a set of random integers equal to the length of the "iteration offset address list" as the iteration offset address list for the superposition operation unit (e.g., iteration_offset), and require:

[0062] a) The generated random number must be greater than the preset minimum value (e.g., 0) and less than "source file size plus extension length" (in bytes).

[0063] b) The elements in the generated iterative offset address list must be distinct from each other.

[0064] c) Arrange the elements in the generated iterative offset address list in ascending order.

[0065] (6-2-3) Randomly generate a positive integer, perform a modulo operation on the integer and 3, and use the resulting value as the iteration operation type (such as iteration_op_type) of the superposition operation unit, where 0 represents iteration operation type one, 1 represents iteration operation type two, and 2 represents iteration operation type three.

[0066] (6-2-4) Set the corresponding iteration operation type header structure according to the iteration operation type of the superposition operation unit (such as iteration_op_type). Specifically:

[0067] (a) If the iteration operation type (e.g., iteration_op_type) of the superposition operation unit is iteration operation type one, then the iteration operation type one header structure of the superposition operation unit is set according to the rules in 3 below.

[0068] (b) If the iteration operation type (e.g., iteration_op_type) of the superposition operation unit is iteration operation type two, then the superposition operation unit's iteration operation type two head structure shall be set according to the rules in 4 below.

[0069] (c) If the iteration operation type of the superposition operation unit (e.g., iteration_op_type) is iteration operation type three, then set the three-head structure of the iteration operation type of the superposition operation unit according to the rules in 5 below.

[0070] If the overlay mode (e.g., overlay_mode) is overlay mode two:

[0071] (6-1) Randomly generate a positive integer that is greater than or equal to a preset minimum value and less than or equal to a preset maximum value. Use the obtained random positive integer that meets the requirements as the length of the overlay offset address list of the basic header in the file header structure (e.g., overlay_offset_len).

[0072] (6-2) Generate a set of random integers equal to the length of the "overlay offset address list" as the overlay offset address list of the basic header in the file header structure (e.g., overlay_offset), and require:

[0073] a) The generated random number must be greater than the preset minimum value (e.g., 0) and less than the "source file size" (in bytes).

[0074] b) The elements in the generated list of offset addresses for the overlay points must be distinct from each other.

[0075] c) Arrange the elements in the generated list of offset addresses of the above overlay points in ascending order.

[0076] (6-3) Set the initial value of the extension length (e.g., extend_len) to 0.

[0077] (6-4) Traverse the list of stacking operation units, starting from the first element of the list (iterate_index = 0) and continuing until the actual stacking count (iteration_number) of the base header in the file header structure. For each stacking operation unit:

[0078] (6-4-1) Set the length of the iteration offset address list of the overlay operation unit (e.g., iteration_offset_len) to the length of the overlay point offset address list of the base header (e.g., overlay_offset_len).

[0079] (6-4-2) Traverse the iterative offset address list of the superposition operation unit, starting from the first element of the iterative offset address list (i=0) at index (e.g., i) and continuing until the length of the iterative offset address list of the superposition operation unit (e.g., iteration_offset_len) elements. For the iterative offset address list:

[0080] The value of the element at the "traversal index (e.g., i)" of the iterative offset address list of the overlay operation unit is set to: the value of the element at the "traversal index (e.g., i)" of the overlay point offset address list of the base header plus an auxiliary increment. The auxiliary increment is: a random ratio multiplied by the extended length and rounded down. The random ratio is an element randomly selected from a set of preset ratio lists, where each element is a number greater than 0 and less than 1.

[0081] (6-4-3) Randomly generate a positive integer, perform a modulo operation on the integer and 3, and use the resulting value as the iteration operation type (such as iteration_op_type) of the superposition operation unit, where 0 represents iteration operation type one, 1 represents iteration operation type two, and 2 represents iteration operation type three.

[0082] If the iteration operation type is iteration operation type two, determine whether the iteration operation type of the previous superposition operation unit is also type two. If it is: randomly generate a positive integer, perform a modulo operation between the integer and 2. If the modulo result is 0, update the iteration operation type to iteration operation type one; otherwise: update the iteration operation type to iteration operation type three.

[0083] (6-4-4) Set the corresponding iteration operation type header structure according to the iteration operation type of the superposition operation unit (such as iteration_op_type). Specifically:

[0084] (a) If the iteration operation type (e.g., iteration_op_type) of the superposition operation unit is iteration operation type one, then the iteration operation type one header structure of the superposition operation unit is set according to the rules in 3 below.

[0085] (b) If the iteration operation type (e.g., iteration_op_type) of the superposition operation unit is iteration operation type two, then the superposition operation unit's iteration operation type two head structure shall be set according to the rules in 4 below.

[0086] (c) If the iteration operation type of the superposition operation unit (e.g., iteration_op_type) is iteration operation type three, then set the three-head structure of the iteration operation type of the superposition operation unit according to the rules in 5 below.

[0087] 3. Set the iterative operation type of the superimposed operation unit to a one-head structure:

[0088] (1) Set the actual number of operation areas (e.g., gap_num) of the iterative operation type of the superposition operation unit to the length of the iterative offset address list of the superposition operation unit.

[0089] (2) Set the list of operation areas for the iterative operation type of the superimposed operation unit with a one-head structure. The specific process is as follows:

[0090] (2-1) Set the temporary append length (e.g., gap_source_addition_len) to the extended length (e.g., extend_len).

[0091] (2-2) Traverse the list of operands, starting from the first element of the list (index = 0) and continuing until the actual number of operands (gap_num) elements are reached. For each operand:

[0092] a) Set the offset address of the operation area to the value of the "traversal index (e.g., index)" element of the iterative offset address list of the superimposed operation unit;

[0093] b) Generate a random integer that is greater than a preset minimum value (e.g., 0) and less than "source file size plus temporary appended length" (in bytes). Use the resulting random integer that meets the requirements as the target offset address of the operation area.

[0094] c) Generate a random integer that is greater than a preset minimum value (e.g., 0) and less than "(source file size plus temporary append length) multiplied by a preset ratio", where the preset ratio is greater than 0 and less than 1.

[0095] The obtained random integer that meets the requirements is used as the operation length of the operation area.

[0096] d) Determine whether the "target offset address + operation length" of the operation area exceeds the "source file size + temporary append length". If it does, subtract the size of the target offset address of the operation area from the "source file size + temporary append length" to get the operation length of the operation area.

[0097] e) Update the extension length (e.g., extend_len) to: the original extension length plus the operation length of the operation area.

[0098] 4. Set the iterative operation type of the superposition operation unit to a two-headed structure:

[0099] (1) Perform a modulo operation on the length of the iterative offset address list of the superposition operation unit and 2. The resulting value is used as the swap type (such as swap_type) of the iterative operation type binary structure of the superposition operation unit. 0 indicates that the swap type is even and 1 indicates that the swap type is odd.

[0100] (2) Randomly generate a positive integer, perform a modulo operation on the integer and 2, and use the resulting value as the swap operation mode (such as swap_op_mode) of the iterative operation type of the superposition operation unit, where 0 represents swap operation mode one and 1 represents swap operation mode two.

[0101] (3) Randomly generate a positive integer, perform a modulo operation between the integer and 3, and use the resulting value as the pairing mode of the iterative operation type of the superposition operation unit (such as swap_match_mode), where 0 represents pairing mode one, 1 represents pairing mode two, and 2 represents pairing mode three.

[0102] (4) If the swap type (e.g., swap_type) is odd, then the iterative offset address list of the superposition operation unit is used as the odd swap offset address list of the two-head structure of the iterative operation type of the superposition operation unit. Otherwise, if the swap type is even, then the iterative offset address list of the superposition operation unit is used as the even swap offset address list of the two-head structure of the iterative operation type of the superposition operation unit.

[0103] (5) Settings for swap length (e.g., swap_len), actual number of pairs (e.g., match_number), odd-numbered pairing list, and even-numbered pairing list. Specifically:

[0104] (5-1) If the swap type (e.g., swap_type) is odd:

[0105] a) Construct a temporary swap offset address list:

[0106] a-1) If the swap operation mode (e.g., swap_op_mode) is of type swap operation mode one:

[0107] The temporary swap offset address list consists of an odd-numbered swap offset address list.

[0108] a-2) If the swap operation mode (e.g., swap_op_mode) is type swap operation mode two: the temporary swap offset address list is formed by adding one element to the beginning and one to the end of the odd swap offset address list. Therefore, the length of the temporary swap offset address list is: odd swap offset address list + 2. And: the first element of the temporary swap offset address list (i.e., the first element) is: 0.

[0109] The last element (i.e., the last element) of the temporary swap offset address list is: source file size + extension length.

[0110] b) Subtract the directly adjacent swap offset addresses in the temporary swap offset address list in order to obtain a set of adjacent differences.

[0111] The length of the resulting adjacent difference is: the length of the temporary swap offset address list - 1.

[0112] c) The minimum value of the obtained adjacent differences is used as the swap region length (e.g., swap_len) of the two-head structure of the iterative operation type of the superposition operation unit.

[0113] d) Divide the length of the resulting set of adjacent differences by 2 and round down to get the actual pairing number (e.g., match_number) of the binomial structure of the superposition operation unit.

[0114] e) The odd-numbered pairing list is set according to the following rules:

[0115] e-1) If the pairing mode (e.g., swap_match_mode) is pairing mode one:

[0116] Iterate through the list of odd-numbered pairs, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1). For each pair:

[0117] Set the swap address of the paired area element to the value of the "traversal index (e.g., index)" element in the temporary swap offset address list.

[0118] Set the swap address of the paired area element to the value of the element in the temporary swap offset address list that is "(index of the last element in the temporary swap offset address list)-1-traversal index".

[0119] e-2) If the pairing mode (e.g., swap_match_mode) is pairing mode two:

[0120] Iterate through the list of odd-numbered pairs, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1). For each pair:

[0121] Set the swap address of the paired area element to the value of the element at the second traversal index (e.g., index) in the temporary swap offset address list.

[0122] Set the swap address of the paired area element to the value of the "2nd traversal index (e.g., index) + 1" element in the temporary swap offset address list.

[0123] e-3) If the pairing mode (e.g., swap_match_mode) is pairing mode three:

[0124] The initial value of the random selection list is set to: a temporary swap offset address list after removing the last element. Therefore, the initial length of this random selection list is: the length of the temporary swap offset address list - 1.

[0125] Iterate through the list of odd-numbered pairs, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1). For each pair:

[0126] Set the swap address of the paired elements to the value of the first element in the list randomly selected.

[0127] Generate a random positive integer. Take the modulo operation between this integer and the length of the random selection list, and use the result as the random selection index. If the random selection index is 0 (i.e., the first element), increment the random selection index by 1.

[0128] The second swap address for the paired elements is set to a value at a randomly selected index position from the list.

[0129] Update the random selection list and its length: Take all elements from the current random selection list except the first element and the element at the random selection index, and construct a new random selection list in order. Use this new random selection list as the new value of the random selection list. Simultaneously, set the length of the new random selection list to "the length of the random selection list - 2".

[0130] (5-2) If the swap type (e.g., swap_type) is even:

[0131] a) Construct a temporary swap offset address list:

[0132] a-1) If the swap operation mode (e.g., swap_op_mode) is of type swap operation mode one:

[0133] The temporary swap offset address list is formed by adding one element to the beginning of the even-numbered swap offset address list. Therefore, the length of the temporary swap offset address list is: even-numbered swap offset address list + 1. And the first element (i.e., the first element) of the temporary swap offset address list is 0.

[0134] a-2) If the swap operation mode (e.g., swap_op_mode) is of type swap operation mode two:

[0135] The temporary swap offset list is formed by adding an element to the end of the even-numbered swap offset list. Therefore, the length of the temporary swap offset list is: even-numbered swap offset list + 1. And the last element of the temporary swap offset list is: source file size + extended length.

[0136] b) Subtract the directly adjacent swap offset addresses in the temporary swap offset address list in order to obtain a set of adjacent differences.

[0137] The length of the resulting adjacent difference is: the length of the temporary swap offset address list - 1.

[0138] c) The minimum value of the obtained adjacent differences is used as the swap region length (e.g., swap_len) of the two-head structure of the iterative operation type of the superposition operation unit.

[0139] d) Divide the length of the resulting set of adjacent differences by 2 and round down to get the actual pairing number (e.g., match_number) of the binomial structure of the superposition operation unit.

[0140] e) The even-numbered pairing list is set according to the following rules:

[0141] e-1) If the pairing mode (e.g., swap_match_mode) is pairing mode one:

[0142] Iterate through the list of even-numbered pairs, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1). For each pair:

[0143] Set the swap address of the paired area element to the value of the "traversal index (e.g., index)" element in the temporary swap offset address list.

[0144] Set the swap address of the paired area element to the value of the element in the temporary swap offset address list that is "(index of the last element in the temporary swap offset address list)-1-traversal index".

[0145] e-2) If the pairing mode (e.g., swap_match_mode) is pairing mode two:

[0146] Iterate through the list of even-numbered pairs, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1). For each pair:

[0147] Set the swap address of the paired area element to the value of the element at the second traversal index (e.g., index) in the temporary swap offset address list.

[0148] Set the swap address of the paired area element to the value of the "2nd traversal index (e.g., index) + 1" element in the temporary swap offset address list.

[0149] e-3) If the pairing mode (e.g., swap_match_mode) is pairing mode three:

[0150] The initial value of the random selection list is set to: a temporary swap offset address list after removing the last element. Therefore, the initial length of this random selection list is: the length of the temporary swap offset address list - 1.

[0151] Iterate through the list of even-numbered pairs, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1). For each pair:

[0152] Set the swap address of the paired elements to the value of the first element in the list randomly selected.

[0153] Generate a random positive integer. Take the modulo operation between this integer and the length of the random selection list, and use the result as the random selection index. If the random selection index is 0 (i.e., the first element), increment the random selection index by 1.

[0154] The second swap address for the paired elements is set to a value at a randomly selected index position from the list.

[0155] Update the random selection list and its length: Take all elements from the current random selection list except the first element and the element at the random selection index, and construct a new random selection list in order. Use this new random selection list as the new value of the random selection list. Simultaneously, set the length of the new random selection list to "the length of the random selection list - 2".

[0156] 5. Set the iterative operation type of the superposition operation unit to a three-head structure:

[0157] (1) Set the temporary append length (e.g., gap_source_addition_len) to the extended length (e.g., extend_len).

[0158] (2) Randomly generate a positive integer, perform a modulo operation between the integer and 2, and use the resulting value as the grouping mode of the three-head structure of the superposition operation unit (such as group_divide_mode), where 0 represents grouping mode one and 1 represents grouping mode two.

[0159] (3) If the grouping mode (e.g., group_divide_mode) is mode one:

[0160] (3-1) Set the actual number of groups (e.g., group_number) of the three-head structure of the iterative operation type of the superposition operation unit to "the length of the iterative offset address list of the superposition operation unit + 1".

[0161] (3-2) The iterative offset address list of the superposition operation unit is used as the operation point offset address list of the three-head structure of the iterative operation type of the superposition operation unit (such as op_offset). That is, the length of the operation point offset address list is "the actual number of groups - 1" (i.e. the length of the iterative offset address list of the superposition operation unit).

[0162] (3-3) Traverse the list of operation groups for the iterative operation type of the superimposed operation unit, starting from the first element of the operation group list (index = 0) and continuing until the actual number of groups (e.g., group_number) elements. For each operation group:

[0163] (3-3-1) Set the "group head node offset address (e.g., group_head_offset)" and "group tail node offset address (e.g., group_tail_offset)" of the operation group.

[0164] a) If it is the first operation group:

[0165] Set the head node offset address of the group (e.g., group_head_offset) to 0;

[0166] Set the tail node offset address of the group (e.g., group_tail_offset) to the value of the "traversal index (e.g., index)" element of the list of operation point offset addresses.

[0167] b) If it is the last operation group:

[0168] Set the offset address of the group's head node (e.g., group_head_offset) to the value of the element at the "traversal index (e.g., index) - 1"th element in the list of operation point offset addresses;

[0169] Set the tail node offset address of the group (e.g., group_tail_offset) to: source file size + temporary append length (in bytes);

[0170] c) For other operation groups:

[0171] Set the offset address of the group's head node (e.g., group_head_offset) to the value of the element at the "traversal index (e.g., index) - 1"th element in the list of operation point offset addresses;

[0172] Set the tail node offset address of the group (e.g., group_tail_offset) to the value of the element at the "traversal index (e.g., index)" of the list of operation point offset addresses;

[0173] (3-3-2) Set the group length of the operation group (e.g., group_len):

[0174] Generate a random integer that is not less than the preset minimum group length (e.g., 3) and not greater than the preset maximum group length. Use the resulting random integer that meets these requirements as the group length (e.g., group_len) for the operation group.

[0175] (3-3-3) Set the list of group offset addresses for the operation group (e.g., group_offset):

[0176] Generate a set of random integers equal to the "group length of the operation group" as a list of group offset addresses for the operation group (e.g., group_offset). The length of the list of group offset addresses is equal to the current group length. The requirements are:

[0177] a) The generated random number must be greater than the "head node offset address of the group" and less than the "tail node offset address of the group".

[0178] b) The elements in the generated list of group offset addresses must be distinct from each other.

[0179] c) Arrange the elements in the generated list of group offset addresses in ascending order.

[0180] (3-3-4) Set the group type of the operation group (e.g., group_type):

[0181] Generate a random positive integer, perform a modulo operation between the integer and 2, and use the resulting value as the group type of the operation group, where 0 represents group type one and 1 represents group type two.

[0182] (3-3-5) If the group type of the operation group is group type one, then set the group type one header structure of the operation group according to the following rule (4):

[0183] (3-3-6) If the group type of the operation group is group type two, then set the group type two header structure of the operation group according to the following rule (5):

[0184] If the grouping mode (such as group_divide_mode) is mode two:

[0185] (3-1) Use the list of iterative offset addresses of the superposition operation unit as the list of operation point offset addresses of the three-head structure of the iterative operation type of the superposition operation unit (such as op_offset).

[0186] (3-2) Set the group length type (e.g., group_len_type) of the iterative operation type of the superposition operation unit:

[0187] A positive integer is randomly generated. The integer is modulo 4. The resulting value is used as the group length type of the three-head structure of the superposition operation unit. 0 represents group length type one, 1 represents group length type two, 2 represents group length type three, and 3 represents group length type four.

[0188] (3-3) Set the actual number of groups (e.g., group_number) of the iterative operation type of the superposition operation unit:

[0189] If the group length type is group length type one, the actual number of groups in the file header structure is set to: the length of the operation point offset address list divided by the preset maximum group length, and rounded up.

[0190] If the group length type is group length type two, the actual number of groups in the file header structure is set to: the length of the operation point offset address list divided by the preset minimum group length, and then rounded down.

[0191] If the group length type is group length type three, set the actual number of groups in the file header structure to the preset number of groups.

[0192] If the group length type is group length type four, a random integer is generated, requiring that the generated random number is not less than the minimum group size and not greater than the maximum group size. The minimum group size is calculated by dividing the length of the operation point offset address list by the preset maximum group length and rounding up, while the maximum group size is calculated by dividing the length of the operation point offset address list by the preset minimum group length and rounding down. The resulting random integer that meets the requirements is used as the actual group size of the iterative operation type three-head structure of the superimposed operation unit.

[0193] (3-4) Traverse the list of operation groups for the iterative operation type of the superimposed operation unit, starting from the first element of the operation group list (index = 0) and continuing until the actual number of groups (e.g., group_number) elements. For each operation group:

[0194] (3-4-1) Set the group length of the operation group (e.g., group_len):

[0195] a) If it is the last operation group:

[0196] The group length of the operation group is set to: "length of the operation point offset address list" minus "traversal index" multiplied by the step size. The step size is calculated as: "length of the operation point offset address list divided by the actual number of groups in the three-headed structure of the iterative operation type of the superimposed operation unit, rounded down".

[0197] b) For other operation groups:

[0198] The group length of the operation group is set as follows: the length of the operation point offset address list divided by the actual number of groups in the three-head structure of the iterative operation type of the superimposed operation unit, and then rounded down.

[0199] (3-4-2) Set the list of group offset addresses for the operation group (e.g., group_offset):

[0200] Iterate through the list of group offset addresses for the operation group, starting from the first element (i=0) of the list and continuing until the group length (e.g., group_len) elements are reached. For each offset address in the list:

[0201] The value at the "offset address index" position of the group offset address list is set to the value of the "operation group traversal index multiplied by the step size plus the offset address index" element of the operation point offset address list of the three-head structure of the iterative operation type of the superimposed operation unit (i.e., operation group traversal index x step size + offset address index). The step size is "the length of the operation point offset address list divided by the actual number of groups in the three-head structure of the iterative operation type of the superimposed operation unit, rounded down".

[0202] (3-4-3) Set the head and tail node mode of the operation group (e.g., group_head_tail_mode):

[0203] A positive integer is randomly generated. The integer is modulo 3. The resulting value is used as the head and tail node pattern of the operation group. 0 represents head and tail node pattern one, 1 represents head and tail node pattern two, and 2 represents head and tail node pattern three.

[0204] (3-4-4) Set the group type of the operation group (e.g., group_type):

[0205] Generate a random positive integer, perform a modulo operation between the integer and 2, and use the resulting value as the group type of the operation group, where 0 represents group type one and 1 represents group type two.

[0206] (3-5) Iterate through the operation group list in the file header structure again, starting from the first element of the operation group list (index = 0) and continuing until the actual number of groups (group_number) elements are reached. For each operation group:

[0207] (3-5-1) Set the "group head node offset address (e.g., group_head_offset)" and "group tail node offset address (e.g., group_tail_offset)" of the operation group.

[0208] If the head and tail node patterns of the operation group are head and tail node pattern one:

[0209] a) If it is the first operation group:

[0210] Set the head node offset address of the group (e.g., group_head_offset) to 0.

[0211] Set the tail node offset address of the group (e.g., group_tail_offset) to the value of the last element in the list of group offset addresses for the current operation group.

[0212] Update the group offset address list (e.g., group_offset) of the operation group to: remove the last element from the original group offset address list of the operation group.

[0213] The update operation group's group length (e.g., group_len) is: the original operation group's group length (e.g., group_len) minus 1.

[0214] b) If it is the last operation group:

[0215] Set the head node offset address of the group (e.g., group_head_offset) to the tail node offset address of the previous operation group.

[0216] Set the tail node offset address of the group (e.g., group_tail_offset) to: source file size + temporary append length (in bytes);

[0217] c) For other operation groups:

[0218] Set the head node offset address of the group (e.g., group_head_offset) to the tail node offset address of the previous operation group.

[0219] Set the tail node offset address of the group (e.g., group_tail_offset) to the value of the last element in the list of group offset addresses for the current operation group.

[0220] Update the group offset address list (e.g., group_offset) of the operation group to: remove the last element from the original group offset address list of the operation group.

[0221] The update operation group's group length (e.g., group_len) is: the original operation group's group length (e.g., group_len) minus 1.

[0222] If the head and tail node pattern of the operation group is head and tail node pattern two:

[0223] a) If it is the first operation group:

[0224] Set the head node offset address of the group (e.g., group_head_offset) to 0.

[0225] Set the tail node offset address of the group (e.g., group_tail_offset) to the value of the first element of the group offset address list for the next operation group.

[0226] b) If it is the last operation group:

[0227] Set the head node offset address of the group (e.g., group_head_offset) to the tail node offset address of the previous operation group.

[0228] Set the tail node offset address of the group (e.g., group_tail_offset) to: source file size + temporary append length (in bytes);

[0229] The update operation group's group length (e.g., group_len) is: the original operation group's group length (e.g., group_len) minus 1.

[0230] Update the group offset address list (e.g., group_offset) of the operation group to: remove the first element from the original group offset address list of the operation group.

[0231] c) For other operation groups:

[0232] Set the head node offset address of the group (e.g., group_head_offset) to the tail node offset address of the previous operation group.

[0233] Set the tail node offset address of the group (e.g., group_tail_offset) to the value of the first element of the group offset address list for the next operation group.

[0234] The update operation group's group length (e.g., group_len) is: the original operation group's group length (e.g., group_len) minus 1.

[0235] Update the group offset address list (e.g., group_offset) of the operation group to: remove the first element from the original group offset address list of the operation group.

[0236] If the head and tail node pattern of the operation group is head and tail node pattern three:

[0237] a) If it is the first operation group:

[0238] Set the head node offset address of the group (e.g., group_head_offset) to 0.

[0239] Set the tail node offset address of the group (e.g., `group_tail_offset`) to: "the value of the last element in the group offset address list of the current operation group" plus "the inter-group difference multiplied by a preset ratio". The inter-group difference is the value of the first element in the group offset address list of the next operation group minus the value of the last element in the group offset address list of the current operation group. The preset ratio must be greater than 0 and less than 1.

[0240] b) If it is the last operation group:

[0241] Set the head node offset address of the group (e.g., group_head_offset) to the tail node offset address of the previous operation group.

[0242] Set the tail node offset address of the group (e.g., group_tail_offset) to: source file size + temporary append length (in bytes);

[0243] c) For other operation groups:

[0244] Set the head node offset address of the group (e.g., group_head_offset) to the tail node offset address of the previous operation group.

[0245] Set the tail node offset address of the group (e.g., `group_tail_offset`) to: "the value of the last element in the group offset address list of the current operation group" plus "the inter-group difference multiplied by a preset ratio". The inter-group difference is the value of the first element in the group offset address list of the next operation group minus the value of the last element in the group offset address list of the current operation group. The preset ratio must be greater than 0 and less than 1.

[0246] (3-5-2) If the group type of the operation group is group type one, then set the group type one header structure of the operation group according to the following rule (4):

[0247] (3-5-3) If the group type of the operation group is group type two, then set the group type two header structure of the operation group according to the following rule (5):

[0248] (4) Set the group type of the operation group to a head structure:

[0249] (4-1) Set the actual number of operation areas (e.g., gap_num) of the group type head structure to the group length of the operation group.

[0250] (4-2) Set up the operation area list of the group type with a head structure. The specific process is as follows:

[0251] (4-2-1) Set the temporary append length (e.g., gap_source_addition_len) to the extended length (e.g., extend_len).

[0252] (4-2-2) Traverse the list of operands, starting from the first element of the list (index = 0) and continuing until the actual number of operands (gap_num) elements are reached. For each operand:

[0253] a) Set the offset address of the operation area to the value of the "traversal index (e.g., index)" element of the group offset address list of the operation group;

[0254] b) Generate a random integer that is greater than a preset minimum value (e.g., 0) and less than "source file size + temporary append length" (in bytes). Use the resulting random integer that meets the requirements as the target offset address of the operation area.

[0255] c) Generate a random integer that is greater than a preset minimum value (e.g., 0) and less than "(source file size + temporary append length) multiplied by a preset ratio", where the preset ratio is greater than 0 and less than 1.

[0256] The obtained random integer that meets the requirements is used as the operation length of the operation area.

[0257] d) Determine whether the "target offset address + operation length" of the operation area exceeds the "source file size + temporary append length". If it does, subtract the size of the target offset address of the operation area from the "source file size + temporary append length" to get the operation length of the operation area.

[0258] e) Update the extension length (e.g., extend_len) to: original extension length + operation length of the operation area.

[0259] (5) Set the group type of the operation group to a two-headed structure:

[0260] (5-1) Perform a modulo operation between the group length of the operation group and 2, and use the resulting value as the swap type (such as swap_type) of the group type binary structure of the operation group, where 0 indicates that the swap type is even and 1 indicates that the swap type is odd.

[0261] (5-2) Randomly generate a positive integer, perform a modulo operation on the integer and 2, and use the resulting value as the swap operation mode (such as swap_op_mode) of the group type two-head structure of the operation group, where 0 represents swap operation mode one and 1 represents swap operation mode two.

[0262] (5-3) Randomly generate a positive integer, perform a modulo operation between the integer and 3, and use the resulting value as the pairing mode of the group type two-head structure of the operation group (such as swap_match_mode), where 0 represents pairing mode one, 1 represents pairing mode two, and 2 represents pairing mode three.

[0263] (5-4) If the swap type (e.g., swap_type) is odd, then the group offset address list of the operation group is used as the odd swap offset address list of the group type two-head structure of the operation group. Otherwise, if the swap type is even, then the group offset address list of the operation group is used as the even swap offset address list of the group type two-head structure of the operation group.

[0264] (5-5) Settings for swap length (e.g., swap_len), actual number of pairs (e.g., match_number), odd-numbered pairing list, and even-numbered pairing list. Specifically:

[0265] If the swap type (such as swap_type) is odd:

[0266] a) Construct a temporary swap offset address list:

[0267] a-1) If the swap operation mode (e.g., swap_op_mode) is of type swap operation mode one:

[0268] The temporary swap offset address list consists of an odd-numbered swap offset address list.

[0269] a-2) If the swap operation mode (e.g., swap_op_mode) is of type swap operation mode two:

[0270] The temporary swap offset address list is constructed by adding one element to the beginning and one to the end of the odd swap offset address list. Therefore, the length of the temporary swap offset address list is: the odd swap offset address list + 2. Furthermore, the first element (the first element) of the temporary swap offset address list is the "head node offset address" of the operation group. The last element (the last element) of the temporary swap offset address list is the "tail node offset address" of the operation group.

[0271] b) Subtract each pair of directly adjacent swap offset addresses in the temporary swap offset address list in sequence to obtain a set of adjacent differences. The length of this set of adjacent differences is: the length of the temporary swap offset address list - 1.

[0272] c) The minimum value of the adjacent differences obtained in this group is taken as the swap length of the group type two-head structure of the operation group (e.g., swap_len).

[0273] d) Divide the length of the adjacent difference obtained in this group by 2 and round down to get the actual number of pairs (e.g., match_number) of the two-headed structure of the group type of the operation group.

[0274] e) The odd-numbered pairing list is set according to the following rules:

[0275] e-1) If the pairing mode (e.g., swap_match_mode) is pairing mode one:

[0276] Iterate through the list of odd-numbered pairs, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1). For each pair:

[0277] Set the swap address of the paired area element to the value of the "traversal index (e.g., index)" element in the temporary swap offset address list.

[0278] Set the swap address of the paired area element to the value of the element in the temporary swap offset address list that is "(index of the last element in the temporary swap offset address list)-1-traversal index".

[0279] e-2) If the pairing mode (e.g., swap_match_mode) is pairing mode two:

[0280] Iterate through the list of odd-numbered pairs, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1). For each pair:

[0281] Set the first swap address of the paired area element to the value of the element at the second traversal index (e.g., index) in the temporary swap offset address list. Set the second swap address of the paired area element to the value of the element at the second traversal index (e.g., index + 1) in the temporary swap offset address list.

[0282] e-3) If the pairing mode (e.g., swap_match_mode) is pairing mode three:

[0283] The initial value of the random selection list is set to: a temporary swap offset address list after removing the last element. Therefore, the initial length of this random selection list is: the length of the temporary swap offset address list - 1.

[0284] Iterate through the list of odd-numbered pairs, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1). For each pair:

[0285] Set the swap address of the paired elements to the value of the first element in the list randomly selected.

[0286] Generate a random positive integer. Take the modulo operation between this integer and the length of the random selection list, and use the result as the random selection index. If the random selection index is 0 (i.e., the first element), increment the random selection index by 1.

[0287] The second swap address for the paired elements is set to a value at a randomly selected index position from the list.

[0288] Update the random selection list and its length: Take all elements from the current random selection list except the first element and the element at the random selection index, and construct a new random selection list in order. Use this new random selection list as the new value of the random selection list. Simultaneously, set the length of the new random selection list to "the length of the random selection list - 2".

[0289] If the swap type (such as swap_type) is even:

[0290] a) Construct a temporary swap offset address list:

[0291] a-1) If the swap operation mode (e.g., swap_op_mode) is of type swap operation mode one:

[0292] The temporary swap offset address list is formed by adding one element to the beginning of the even-numbered swap offset address list. Therefore, the length of the temporary swap offset address list is: even-numbered swap offset address list + 1. Furthermore, the first element (the first element) of the temporary swap offset address list is: the "head node offset address" of the operation group.

[0293] a-2) If the swap operation mode (e.g., swap_op_mode) is of type swap operation mode two:

[0294] The temporary swap offset address list is formed by adding an element to the end of the even-numbered swap offset address list. Therefore, the length of the temporary swap offset address list is: even-numbered swap offset address list + 1. And the last element of the temporary swap offset address list is: the "tail node offset address of the operation group".

[0295] b) Subtract each pair of directly adjacent swap offset addresses in the temporary swap offset address list in sequence to obtain a set of adjacent differences. The length of this set of adjacent differences is: the length of the temporary swap offset address list - 1.

[0296] c) The minimum value of the adjacent differences obtained in this group is taken as the swap length of the group type two-head structure of the operation group (e.g., swap_len).

[0297] d) Divide the length of the adjacent difference obtained in this group by 2 and round down to get the actual number of pairs (e.g., match_number) of the two-headed structure of the group type of the operation group.

[0298] e) The even-numbered pairing list is set according to the following rules:

[0299] e-1) If the pairing mode (e.g., swap_match_mode) is pairing mode one:

[0300] Iterate through the list of even-numbered pairs, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1). For each pair:

[0301] Set the swap address of the paired area element to the value of the "traversal index (e.g., index)" element in the temporary swap offset address list.

[0302] Set the swap address of the paired area element to the value of the element in the temporary swap offset address list that is "(index of the last element in the temporary swap offset address list)-1-traversal index".

[0303] e-2) If the pairing mode (e.g., swap_match_mode) is pairing mode two:

[0304] Iterate through the list of even-numbered pairs, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1). For each pair:

[0305] Set the swap address of the paired area element to the value of the element at the second traversal index (e.g., index) in the temporary swap offset address list.

[0306] Set the swap address of the paired area element to the value of the "2nd traversal index (e.g., index) + 1" element in the temporary swap offset address list.

[0307] e-3) If the pairing mode (e.g., swap_match_mode) is pairing mode three:

[0308] The initial value of the random selection list is set to: a temporary swap offset address list after removing the last element. Therefore, the initial length of this random selection list is: the length of the temporary swap offset address list - 1.

[0309] Iterate through the list of even-numbered pairs, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1). For each pair:

[0310] Set the swap address of the paired elements to the value of the first element in the list randomly selected.

[0311] Generate a random positive integer. Take the modulo operation between this integer and the length of the random selection list, and use the result as the random selection index. If the random selection index is 0 (i.e., the first element), increment the random selection index by 1.

[0312] The second swap address for the paired elements is set to a value at a randomly selected index position from the list.

[0313] Update the random selection list and its length: Take all elements from the current random selection list except the first element and the element at the random selection index, and construct a new random selection list in order. Use this new random selection list as the new value of the random selection list. Simultaneously, set the length of the new random selection list to "the length of the random selection list - 2".

[0314] In some embodiments, encrypting the file header structure and forming a second protected file based on the encrypted file header structure and the first protected file includes: encrypting the constructed base header using an encryption algorithm; when the size of the encrypted base header is equal to the size of the base header before encryption, and the size of the encrypted superposition operation unit list is equal to the size of the superposition operation unit list before encryption, writing the encrypted base header into the header of the empty protected file, and simultaneously writing the encrypted superposition operation unit list into the current tail of the empty protected file; when the size of the encrypted base header is not equal to the size of the base header before encryption, or the size of the encrypted superposition operation unit list is not equal to the size of the superposition operation unit list before encryption, constructing an auxiliary header of a preset size, then writing the auxiliary header into the header of the empty protected file, and writing the encrypted base header into the current tail of the empty protected file, wherein the auxiliary header includes a preset magic number, the size of the encrypted base header, and the size of the encrypted superposition operation unit list.

[0315] For example, the base header of a pre-defined size is encrypted using a pre-defined symmetric encryption algorithm and key. The list of overlay operation units is also encrypted using a pre-defined symmetric encryption algorithm and key.

[0316] Then, determine whether the size of the encrypted base header is equal to the preset size of the base header before encryption:

[0317] a) If the size of the base header before and after encryption is not equal, then proceed to step b. Otherwise, if the size of the base header before and after encryption is equal, then:

[0318] a-1) Determine whether the size of the encrypted superposition operation unit list is equal to the size of the unencrypted superposition operation unit list. If they are not equal, proceed to step b; otherwise, if they are equal, proceed to step a-2.

[0319] a-2) Write the encrypted base header to the header of the AI ​​protected model file (e.g., protected_model.pb), and write the encrypted list of overlay operation units to the current tail of the AI ​​protected model file (e.g., protected_model.pb), i.e., after the encrypted base header.

[0320] Use "the size of the encrypted base header + the size of the encrypted stacking operation unit list" as the model header length (e.g., protected_model_header_len).

[0321] (b) Construct an auxiliary header of a preset size, which includes three pieces of information: the preset magic number, the size of the encrypted base header, and the size of the encrypted stacking operation unit list. Then, write the auxiliary header into the header of the AI-protected model file (e.g., protected_model.pb), and write the encrypted base header and the encrypted stacking operation unit list sequentially into the current tail of the AI-protected model file (e.g., protected_model.pb).

[0322] Use "the size of the auxiliary header (preset size) + the size of the encrypted base header + the size of the encrypted overlay operation unit list" as the model header length (e.g., protected_model_header_len).

[0323] This embodiment also includes allocating intermediate buffer one and intermediate buffer two. Intermediate buffer one and intermediate buffer two can be either memory buffers or files. If a memory buffer is used, its size is at least: the size of the source model file + the extended length.

[0324] In some embodiments, processing the source file according to the file header structure and forming a third protected file based on the processed source file and the second protected file includes: traversing the list of overlay operation units, with the traversal index (e.g., iterate_index) starting from the first element of the list of overlay operation units (iterate_index = 0) and continuing until the actual number of overlays (e.g., iteration_number) of the base header in the file header structure. The value of the traversal index (e.g., iterate_index) starts from 0 and continues until "the actual number of overlays of the base header in the file header structure - 1".

[0325] For each superposition operation unit:

[0326] (8-1) Buffer settings.

[0327] (8-1-1) If the traversal index is 0 (i.e., the first unit of the stack operation):

[0328] a) Initialize intermediate buffer one and intermediate buffer two, read the source file into intermediate buffer one; set the source buffer length to the source file size; set the target buffer length to 0.

[0329] b) Set the source buffer to intermediate buffer one.

[0330] c) Set the target buffer to intermediate buffer two.

[0331] (8-1-2) If the traversal index is a different value:

[0332] a) If the traversal index is even:

[0333] Set the source buffer to intermediate buffer one.

[0334] Set the target buffer to intermediate buffer two.

[0335] Update the source buffer length to the target buffer length.

[0336] Initialize the target buffer and update its length to 0.

[0337] b) Otherwise, the traversal index is odd:

[0338] Set the source buffer to intermediate buffer two.

[0339] Set the target buffer to intermediate buffer one.

[0340] Update the source buffer length to the target buffer length.

[0341] Initialize the target buffer and update its length to 0.

[0342] (8-2) Perform an iterative operation based on the iterative operation type of the current superposition operation unit.

[0343] (a) If the iteration operation type (e.g., iteration_op_type) is iteration operation type one, then the operation specified by iteration operation type one is performed according to the rules in 9 below.

[0344] (b) If the iteration operation type (e.g., iteration_op_type) is iteration operation type two, then the operation specified by iteration operation type two shall be performed in accordance with the rules in 10 below.

[0345] (c) If the iteration operation type (e.g., iteration_op_type) is iteration operation type three, then the operation specified by iteration operation type three shall be performed in accordance with the rules in 11 below.

[0346] (8-3) If the traversal index is "the actual number of times the basic header is stacked in the file header structure - 1" (i.e., the last stacking operation unit):

[0347] Position the protected file at the "File Header Length" position.

[0348] Write the data in the target buffer to the protected file (e.g., protected_model.pb), with the write length being the length of the target buffer, thus completing the construction of the protected file.

[0349] 9. Specific operation process for iterative operation type one:

[0350] (9-1) The current offset position of the target buffer is initialized to 0.

[0351] (9-2) Traverse the list of operands in the one-head structure of the iterative operation type of the superimposed operation unit, starting from the first element of the operand list (index = 0) and continuing until the actual number of operands (e.g., gap_num) elements of the one-head structure of the iterative operation type of the superimposed operation unit. For each operand:

[0352] (9-2-1) If it is the first operation area:

[0353] a) Position the target buffer at the "current offset position of the target buffer".

[0354] Obtain the offset address of the operation area, use this offset address as the read length, then locate the beginning of the source buffer, read data of the size of the "offset address of the operation area" into a temporary buffer, and then write the data in the temporary buffer into the target buffer.

[0355] Update the current offset position of the target buffer to: the current offset position of the original target buffer + the offset address of the current operation area.

[0356] b) Position the target buffer at the "current offset position of the target buffer".

[0357] Position the source buffer to the target offset address of the current operation area, read the data of the current operation area's operation length into a temporary buffer, and then write the data in that buffer into the target buffer.

[0358] Update the current offset position of the target buffer to: the current offset position of the original target buffer + the operation length of the current operation area.

[0359] (9-2-2) If it is the last operation area: use the offset address of this operation area as the offset address of the current operation area, and use the offset address of the operation area preceding this operation area as the auxiliary offset address. Then:

[0360] a) Position the target buffer at the "current offset position of the target buffer".

[0361] Position the source buffer to the auxiliary offset address, read data of length "current operation area offset address minus auxiliary offset address" into a temporary buffer, and then write the data in the temporary buffer into the target buffer.

[0362] Update the current offset position of the target buffer to: the current offset position of the original target buffer + "the current operation area offset address minus the auxiliary offset address".

[0363] b) Position the target buffer at the "current offset position of the target buffer".

[0364] Position the source buffer to the target offset address of the current operation area, read the data of the current operation area's operation length into a temporary buffer, and then write the data in that buffer into the target buffer.

[0365] Update the current offset position of the target buffer to: the current offset position of the original target buffer + the operation length of the current operation area.

[0366] c) Position the target buffer to the "current offset position of the target buffer".

[0367] Position the source buffer to the offset address of the last operation area, read data of length "source buffer length minus the offset address of the last operation area" into a temporary buffer, and then write the data in the temporary buffer into the target buffer.

[0368] Update the current offset position of the target buffer to: the current offset position of the original target buffer + "the length of the source buffer minus the offset address of the last operation area".

[0369] Set the target buffer length to: the current offset position of the target buffer.

[0370] (9-2-3) For other operation areas: use the offset address of this operation area as the offset address of the current operation area, and use the offset address of the operation area preceding this operation area as the auxiliary offset address. Then:

[0371] a) Position the target buffer at the "current offset position of the target buffer".

[0372] Position the source buffer to the auxiliary offset address, read data of length "current operation area offset address minus auxiliary offset address" into a temporary buffer, and then write the data in the temporary buffer into the target buffer.

[0373] Update the current offset position of the target buffer to: the current offset position of the original target buffer + "the current operation area offset address minus the auxiliary offset address".

[0374] b) Position the target buffer at the "current offset position of the target buffer".

[0375] Position the source buffer to the target offset address of the current operation area, read the data of the current operation area's operation length into a temporary buffer, and then write the data in that buffer into the target buffer.

[0376] Update the current offset position of the target buffer to: the current offset position of the original target buffer + the length of the operation to read the current operation area.

[0377] 10. Specific operation process for iterative operation type two:

[0378] (10-1):

[0379] a) If the swap type (e.g., swap_type) of the iteration operation type binary structure of the superimposed operation unit is odd: Set the temporary pairing list to the odd pairing list of the iteration operation type binary structure of the superimposed operation unit.

[0380] b) Otherwise, if the swap type (e.g., swap_type) of the iteration operation type of the superposition operation unit is even, set the temporary pairing list to the even-numbered pairing list of the iteration operation type of the superposition operation unit.

[0381] (10-2) Read data of the length of the source buffer into the target buffer from the beginning of the source buffer.

[0382] Set the target buffer length to: the source buffer length.

[0383] (10-3) Iterate through the list of temporary pairing regions, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1) elements in the file header structure. For each pairing region:

[0384] a) Locate the target buffer to "Swap address one of paired elements", and read data of size "Swap length of the iterative operation type of the superimposed operation unit" into temporary buffer one.

[0385] b) Locate the target buffer to "the second swap address of the paired elements", and read data of size "the length of the swap area of ​​the iterative operation type of the superimposed operation unit" into temporary buffer two.

[0386] c) Locate the target buffer to "the swap address of the paired area element", and then write the data in the temporary buffer 2. The length of the written data is "the swap length of the iterative operation type of the superimposed operation unit".

[0387] d) Locate the target buffer to "the second swap address of the paired area element", and then write the data in the temporary buffer one. The length of the written data is "the swap area length of the iterative operation type two-head structure of the superimposed operation unit".

[0388] 11. Specific operation process for iterative operation type three:

[0389] (11-1) The current offset position of the target buffer is initialized to 0.

[0390] (11-2) Traverse the list of operation groups for the iterative operation type of the superimposed operation unit, starting from the first element of the operation group list (index = 0) and continuing until the actual number of groups (e.g., group_number) elements. For each operation group:

[0391] (11-2-1) If the group type of the operation group is group type one:

[0392] Iterate through the list of operands in the group-type head structure of the operation group, starting from the first element of the operand list (index = 0) and continuing until the actual number of operands in the group-type head structure (e.g., gap_num). For each operand:

[0393] (11-2-1-1) If it is the first operation area:

[0394] a) Position the target buffer at the "current offset position of the target buffer".

[0395] Obtain the offset address of the operation area, use the offset address as the read length, then locate the source buffer to the "group head node offset address" of the operation group, read data of the size of "operation area offset address minus group head node offset address" into a temporary buffer, and then write the data in the buffer into the target buffer.

[0396] Update the current offset position of the target buffer to: the current offset position of the original target buffer + "the offset address of the operation area minus the offset address of the head node of the group".

[0397] b) Position the target buffer at the "current offset position of the target buffer".

[0398] Position the source buffer to the target offset address of the current operation area, read the data of the current operation area's operation length into a temporary buffer, and then write the data in that buffer into the target buffer.

[0399] Update the current offset position of the target buffer to: the current offset position of the original target buffer + the operation length of the current operation area.

[0400] (11-2-1-2) If it is the last operation area: use the offset address of this operation area as the offset address of the current operation area, and use the offset address of the operation area preceding this operation area as the auxiliary offset address. Then:

[0401] a) Position the target buffer at the "current offset position of the target buffer".

[0402] Position the source buffer to the auxiliary offset address, read data of length "current operation area offset address minus auxiliary offset address" into a temporary buffer, and then write the data in the temporary buffer into the target buffer.

[0403] Update the current offset position of the target buffer to: the current offset position of the original target buffer + "the current operation area offset address minus the auxiliary offset address".

[0404] b) Position the target buffer at the "current offset position of the target buffer".

[0405] Position the source buffer to the target offset address of the current operation area, read the data of the current operation area's operation length into a temporary buffer, and then write the data in that buffer into the target buffer.

[0406] Update the current offset position of the target buffer to: the current offset position of the original target buffer + the operation length of the current operation area.

[0407] c) Position the target buffer to the "current offset position of the target buffer".

[0408] Position the source buffer to the offset address of the last operation area, read data of length "the offset address of the tail node of the group minus the offset address of the last operation area" into a temporary buffer, and then write the data in the temporary buffer into the target buffer.

[0409] Update the current offset position of the target buffer to: the current offset position of the original target buffer + "the offset address of the tail node of the group minus the offset address of the last operation area".

[0410] (11-2-1-3) For other operation areas: use the offset address of this operation area as the offset address of the current operation area, and use the offset address of the operation area preceding this operation area as the auxiliary offset address. Then:

[0411] a) Position the target buffer at the "current offset position of the target buffer".

[0412] Position the source buffer to the auxiliary offset address, read data of length "current operation area offset address minus auxiliary offset address" into a temporary buffer, and then write the data in the temporary buffer into the target buffer.

[0413] Update the current offset position of the target buffer to: the current offset position of the original target buffer + "the current operation area offset address minus the auxiliary offset address".

[0414] b) Position the target buffer at the "current offset position of the target buffer".

[0415] Position the source buffer to the target offset address of the current operation area, read the data of the current operation area's operation length into a temporary buffer, and then write the data in that buffer into the target buffer.

[0416] Update the current offset position of the target buffer to: the current offset position of the original target buffer + the operation length of the current operation area.

[0417] (11-2-2) If the group type of the operation group is group type two:

[0418] Position the target buffer at the "current offset position of the target buffer".

[0419] The source buffer is located at the "head node offset address" of the operation group. Data of the length "tail node offset address minus head node offset address" of the operation group is read into a temporary buffer. Then, the data in this buffer is written into the target buffer.

[0420] Update the current offset position of the target buffer to: the current offset position of the original target buffer + "the offset address of the tail node of the group minus the offset address of the head node of the group".

[0421] (11-2-3) If this operation group is the last operation group:

[0422] Set the target buffer length to: the current offset position of the target buffer.

[0423] (11-3) Set the initial value of the temporary auxiliary length to 0.

[0424] Then iterate through the list of operation groups in the file header structure again, starting from the first element of the operation group list (index = 0) and continuing until the actual number of groups (group_number) elements are reached. For each operation group:

[0425] (11-3-1) If the group type of the operation group is group type one:

[0426] Iterate through the list of operands in the group-type head structure of the operation group, starting from the first element of the operand list (index = 0) and continuing until the actual number of operands in the group-type head structure (e.g., gap_num). For each operand:

[0427] Update the temporary auxiliary length to: the original temporary auxiliary length plus the current operation length of the operation area.

[0428] (11-3-2) If the group type of the operation group is group type two:

[0429] (11-3-2-1) If the swap type (e.g., swap_type) of the group type binary structure of the operation group is odd: set the temporary pairing list to the odd pairing list of the group type binary structure of the operation group; otherwise, if the swap type (e.g., swap_type) of the group type binary structure of the operation group is even: set the temporary pairing list to the even pairing list of the group type binary structure of the operation group.

[0430] (11-3-2-2) Iterate through the list of temporary pairing regions, starting from the first element of the list (index = 0) and continuing until the actual number of pairs (match_number - 1) elements in the file header structure. For each pairing region:

[0431] a) Locate the target buffer to "the swap address of the paired element plus the temporary auxiliary length", and read data of size "the swap length of the group type two-head structure of the operation group" into the temporary buffer one.

[0432] b) Locate the target buffer to "the swap address of the paired element plus the temporary auxiliary length", and read data of size "the swap length of the group type two-head structure of the operation group" into the temporary buffer two.

[0433] c) Locate the target buffer to "the swap address of the paired area element plus the temporary auxiliary length", and then write the data in the temporary buffer two. The length of the written data is "the swap area length of the group type two-head structure of the operation group".

[0434] d) Locate the target buffer to "the swap address of the paired element plus the temporary auxiliary length", and then write the data in the temporary buffer one. The length of the written data is "the swap length of the group type two-head structure of the operation group".

[0435] In some embodiments, the file processing method may further include obtaining the source file, which includes an artificial intelligence source model file.

[0436] In some embodiments, after the third protection file is generated, the file processing method may further include performing publishing and deployment based on the third protection file.

[0437] According to embodiments of this disclosure, the source file is randomly corrupted by constructing a file header structure, and the random corruption rules are encrypted and written into the source file header. Because the source file is randomly corrupted, the corrupted content is different each time for the same source file, resulting in different protected files after corruption, thus maximizing the confidentiality and security of the source file protection. Simultaneously, since the entire source file is not encrypted, the demand for computing resources is reduced while protecting the source file.

[0438] Figure 2 This is another flowchart illustrating a file processing method according to an embodiment of the present disclosure. Figure 2 As shown, the file processing method includes the following steps S210 to S230.

[0439] In step S210, a protected file is received, the protected file including first information associated with an encrypted file header structure and second information associated with a processed source file obtained by processing the source file according to the file header structure, wherein the file header structure is constructed based on a random number of superposition operations on the source file and the operation type.

[0440] In step S210, the first information of the protected file is verified based on a preset file header structure.

[0441] like Figure 3 As shown, verifying the first information of the protected file based on the preset file header structure includes the following steps S221 to S223.

[0442] In step S221, the encrypted file header structure is derived from the header of the protected file.

[0443] In step S222, the encrypted file header structure is decrypted using a preset symmetric encryption algorithm and key.

[0444] In step S223, the decrypted file header structure is verified based on the preset file header structure.

[0445] Specifically, in this embodiment, verification is performed based on the method of encrypting the file header structure. The verification of the protected file header in this embodiment adopts the following method:

[0446] Read the auxiliary header of a preset size from the header of the protected file, and determine whether the magic number of the auxiliary header is the same as the preset magic number:

[0447] 1-1) If they are the same:

[0448] a) After locating the protected file to the auxiliary header, read data of a specified size into a temporary buffer based on the "size of the encrypted base header" in the auxiliary header, and use it as the encrypted base header. Then, locate the protected file to the "preset size of the auxiliary header + size of the encrypted base header," and simultaneously read data of a specified size into a temporary buffer based on the "size of the encrypted overlay operation unit list" in the auxiliary header, and use it as the encrypted overlay operation unit list.

[0449] b) Use "the preset size of the auxiliary header + the size of the encrypted base header + the size of the encrypted overlay operation unit list" as the temporary header length of the file (e.g., protected_model_header_len).

[0450] c) Use a preset symmetric encryption algorithm and key to decrypt the encrypted base header in the temporary buffer to obtain the decrypted base header.

[0451] Determine if the protected magic number in the decrypted base header is the same as the preset protected magic number: if they are the same, use the preset symmetric encryption algorithm and key to decrypt the list of superposition operation units in the temporary buffer to obtain the decrypted list of superposition operation units. Otherwise, indicate an invalid file and exit.

[0452] (1-2) Otherwise, it means that the magic number of the auxiliary head is different from the preset magic number, then:

[0453] a) Locate the header of the protected file, read the base header of the preset size into a temporary buffer, and use it as the base header for encryption.

[0454] b) Use a preset symmetric encryption algorithm and key to decrypt the encrypted base header in the temporary buffer to obtain the decrypted base header.

[0455] Check if the protection magic number in the decrypted base header is the same as the preset protection magic number: if they are different, indicate an invalid file and exit; otherwise (meaning they are the same):

[0456] b-1) After locating the protected file to the base header, read the data of "the actual number of overlays in the base header multiplied by the length of the overlay operation unit in the base header" into a temporary buffer as the encrypted overlay operation unit list.

[0457] b-2) The default size of the base header plus "the actual number of stacking operations in the base header multiplied by the length of the stacking operation unit in the base header" is used as the temporary header length of the file (e.g., protected_model_header_len).

[0458] b-3) Use a preset symmetric encryption algorithm and key to decrypt the list of superposition operation units in the temporary buffer to obtain the decrypted list of superposition operation units.

[0459] In step S220, in response to the first information of the protected file being verified, the source file is derived based on the second information of the protected file.

[0460] In some embodiments, such as Figure 4As shown, deriving the source file based on the second information of the protected file includes the following steps S231 and S232.

[0461] In step S231, the processed source file is derived from the end of the protected file.

[0462] In step S232, the source file is decoded from the processed source file according to the file header structure, and the source file is stored in the target buffer.

[0463] In addition, some embodiments include allocating intermediate buffer one and intermediate buffer two.

[0464] Among them, intermediate buffer one and intermediate buffer two can be either memory buffers or files. If a memory buffer is used, its size is at least the size of the protected model file.

[0465] In this embodiment, the specific implementation of decoding the source file from the protected file and storing the source file in the target buffer is as follows:

[0466] Iterate through the list of stacking operation units, starting with the last element (e.g., iterate_index = iteration_number - 1) and working towards the first element. The value of the iterate_index starts from "the actual number of stacks in the base header structure in the file header structure - 1" (i.e., the last element) and continues until 0 (i.e., the first element). For each stacking operation unit:

[0467] (3-1) Buffer settings.

[0468] (3-1-1) If the traversal index is "the actual number of times the basic header is stacked in the file header structure - 1" (i.e., the last stacking operation unit):

[0469] a) Initialize intermediate buffer one and intermediate buffer two.

[0470] Locate the protected file to the length of the temporary header (e.g., protected_model_header_len), and read data of "protected file size - temporary header length" into intermediate buffer one.

[0471] Set the source buffer length to "protected file size - file temporary header length".

[0472] Set the target buffer length to 0.

[0473] b) Set the source buffer to intermediate buffer one.

[0474] c) Set the target buffer to intermediate buffer two.

[0475] (3-1-2) If the traversal index is a different value:

[0476] Determine if the parity of the traversal index is the same as that of the index of the last element of the stacking operation unit (i.e., "the actual stacking count of the basic header in the file header structure - 1").

[0477] a) If the parity is the same:

[0478] Set the source buffer to intermediate buffer one.

[0479] Set the target buffer to intermediate buffer two.

[0480] Update the source buffer length to the target buffer length.

[0481] Initialize the target buffer and update its length to 0.

[0482] b) Otherwise, the parity is different:

[0483] Set the source buffer to intermediate buffer two.

[0484] Set the target buffer to intermediate buffer one.

[0485] Update the source buffer length to the target buffer length.

[0486] Initialize the target buffer and update its length to 0.

[0487] (3-2) Perform the iteration operation according to the iteration operation type of the current superposition operation unit.

[0488] (a) If the iteration operation type (e.g., iteration_op_type) is iteration operation type one, then the decoding operation specified by iteration operation type one is performed according to the rules in 4 below.

[0489] (b) If the iteration operation type (e.g., iteration_op_type) is iteration operation type two, then the decoding operation specified by iteration operation type two shall be performed in accordance with the rules in 5 below.

[0490] (c) If the iteration operation type (e.g., iteration_op_type) is iteration operation type three, then the decoding operation specified by iteration operation type three shall be performed in accordance with the rules in 6 below.

[0491] (3-3) If the traversal index is 0 (i.e., the first unit of the stacking operation):

[0492] The data in the target buffer is the final decoded target file data, and the data length is the target buffer length.

[0493] 4. The specific process of the decoding operation specified by iteration operation type one is as follows:

[0494] (4-1) The current offset position of the target buffer is initialized to 0.

[0495] (4-2) Traverse the list of operands in the one-head structure of the iterative operation type of the superimposed operation unit, starting from the first element of the operand list (index = 0) and continuing until the actual number of operands (e.g., gap_num) elements of the one-head structure of the iterative operation type of the superimposed operation unit. For each operand:

[0496] (4-2-1) If it is the first operation area:

[0497] Use the offset address of the current operation area as the offset address of the current operation area, and also use the operation length of the current operation area as the operation length of the current operation area. Then:

[0498] a) Position the target buffer at the "current offset position of the target buffer".

[0499] Position the source buffer to 0, and then read data of size "current operation area offset address" into the target buffer.

[0500] Update the current offset position of the target buffer to: the current offset position of the original target buffer + the offset address of the current operation area.

[0501] b) For each operation area after this operation area, update the corresponding operation area offset address to: original offset address + current operation area length.

[0502] (4-2-2) If it is the last operation area:

[0503] The offset address of this operation area is used as the current operation area offset address, the operation length of this operation area is used as the current operation area operation length, the offset address of the previous operation area is used as the auxiliary offset address, and the operation length of the previous operation area is used as the auxiliary operation length. Then:

[0504] a) Position the target buffer at the "current offset position of the target buffer".

[0505] Position the source buffer to "auxiliary offset address + auxiliary operation length", and read data of length "current operation area offset address - (auxiliary offset address + auxiliary operation length)" into the target buffer.

[0506] Update the current offset position of the target buffer to: the current offset position of the original target buffer + ("current operation area offset address - (auxiliary offset address + auxiliary operation length)").

[0507] b) Position the target buffer at the "current offset position of the target buffer".

[0508] Position the source buffer to "current operation area offset address + current operation area operation length", and read data of length "source buffer length - (current operation area offset address + current operation area operation length)" into the target buffer.

[0509] Update the current offset position of the target buffer to: the current offset position of the original target buffer + ("source buffer length - (current operation area offset address + current operation area operation length)").

[0510] Set the target buffer length to: the current offset position of the target buffer.

[0511] (4-2-3) For other operating areas:

[0512] The offset address of this operation area is used as the current operation area offset address, the operation length of this operation area is used as the current operation area operation length, the offset address of the previous operation area is used as the auxiliary offset address, and the operation length of the previous operation area is used as the auxiliary operation length. Then:

[0513] a) Position the target buffer at the "current offset position of the target buffer".

[0514] Position the source buffer to "auxiliary offset address + auxiliary operation length", and read data of length "current operation area offset address - (auxiliary offset address + auxiliary operation length)" into the target buffer.

[0515] Update the current offset position of the target buffer to: the current offset position of the original target buffer + ("current operation area offset address - (auxiliary offset address + auxiliary operation length)").

[0516] b) For each operation area after this operation area, update the corresponding operation area offset address to: original offset address + current operation area length.

[0517] 5. The specific process of the decoding operation specified in iterative operation type two is as follows:

[0518] (1) If the swap type (e.g., swap_type) of the iteration operation type binary structure of the superposition operation unit is odd: Set the temporary pairing list to the odd-numbered pairing list of the iteration operation type binary structure of the superposition operation unit. Otherwise, if the swap type (e.g., swap_type) of the iteration operation type binary structure of the superposition operation unit is even: Set the temporary pairing list to the even-numbered pairing list of the iteration operation type binary structure of the superposition operation unit.

[0519] (2) Read data of the length of the source buffer from the beginning of the source buffer into the target buffer. Set the length of the target buffer to the length of the source buffer.

[0520] (3) Traverse the temporary pairing list, starting from the first element of the temporary pairing list (index = 0) and continuing until the actual number of pairs (match_number - 1) of the binary structure of the superposition operation unit's iteration operation type. For each pairing:

[0521] a) Locate the target buffer at the swap address one of the paired area elements, and read data of size "the swap length of the iterative operation type of the superimposed operation unit" into temporary buffer one.

[0522] b) Locate the target buffer to the swap address two of the paired area elements, and read data of size "the swap length of the iterative operation type two-head structure of the superimposed operation unit" into temporary buffer two.

[0523] c) Locate the target buffer to the swap address one of the paired area elements, and then write the data in the temporary buffer two. The length of the written data is "the swap area length of the iterative operation type of the superimposed operation unit".

[0524] d) Locate the target buffer to the swap address two of the paired area elements, and then write the data in temporary buffer one. The length of the written data is "the swap area length of the iterative operation type two-head structure of the superimposed operation unit".

[0525] 6. The specific process of the decoding operation specified by iterative operation type three is as follows:

[0526] (6-1) Set the initial value of the temporary auxiliary length to 0.

[0527] The current offset position of the target buffer is initialized to 0.

[0528] (6-2) Traverse the list of operation groups for the iterative operation type of the superimposed operation unit, starting from the first element of the operation group list (index = 0) and continuing until the actual number of groups (e.g., group_number) elements. For each operation group:

[0529] (6-2-1) If the group type of the operation group is group type one:

[0530] Iterate through the list of operands in the group-type head structure of the operation group, starting from the first element of the operand list (i=0) at index i, until the actual number of operands in the group-type head structure (e.g., gap_num). For each operand:

[0531] (6-2-1-1) If it is the first operation area:

[0532] Use the offset address of the current operation area as the offset address of the current operation area, and also use the operation length of the current operation area as the operation length of the current operation area. Then:

[0533] a) Position the target buffer at the "current offset position of the target buffer".

[0534] Position the source buffer to the "group head node offset address + temporary auxiliary length" of the operation group, and then read data of size "(current operation area offset address + temporary auxiliary length) - ("group head node offset address" + temporary auxiliary length)" into the target buffer.

[0535] Update the current offset position of the target buffer to: the current offset position of the original target buffer + ("(current operation area offset address + temporary auxiliary length) - ("group head node offset address" + temporary auxiliary length)").

[0536] b) Update the temporary auxiliary length to: the original temporary auxiliary length plus the current operation length of the operation area.

[0537] (6-2-1-2) If it is the last operation area:

[0538] The offset address of the current operation area is used as the offset address of the current operation area, the operation length of the current operation area is used as the operation length of the current operation area, and the "offset address of the previous operation area + temporary auxiliary length" of the current operation area is used as the auxiliary offset address. Then:

[0539] a) Position the target buffer at the "current offset position of the target buffer".

[0540] Position the source buffer to the "auxiliary offset address" and read data of length "current operation area offset address + temporary auxiliary length - auxiliary offset address" into the target buffer.

[0541] Update the current offset position of the target buffer to: the current offset position of the original target buffer + ("current operation area offset address + temporary auxiliary length - auxiliary offset address").

[0542] b) Position the target buffer at the "current offset position of the target buffer".

[0543] Position the source buffer to "current operation area offset address + temporary auxiliary length + current operation area operation length", and read data of length "'group tail node offset address' + temporary auxiliary length + current operation area operation length - (current operation area offset address + temporary auxiliary length + current operation area operation length)" into the target buffer.

[0544] Update the current offset position of the target buffer to: the current offset position of the original target buffer + ("the 'tail node offset address of the operation group' + temporary auxiliary length + current operation area length - (current operation area offset address + temporary auxiliary length + current operation area length)").

[0545] c) If the current operation group is not the last operation group in the list of operation groups of the iterative operation type three-head structure of the superimposed operation unit, then: update the temporary auxiliary length to: the original temporary auxiliary length plus the operation length of the current operation area.

[0546] (6-2-1-3) For other operating areas:

[0547] The offset address of the current operation area is used as the offset address of the current operation area, the operation length of the current operation area is used as the operation length of the current operation area, and the "offset address of the previous operation area + temporary auxiliary length" of the current operation area is used as the auxiliary offset address. Then:

[0548] a) Position the target buffer at the "current offset position of the target buffer".

[0549] Position the source buffer to the "auxiliary offset address" and read data of length "current operation area offset address + temporary auxiliary length - auxiliary offset address" into the target buffer.

[0550] Update the current offset position of the target buffer to: the current offset position of the original target buffer + ("current operation area offset address + temporary auxiliary length - auxiliary offset address").

[0551] b) Update the temporary auxiliary length to: the original temporary auxiliary length plus the current operation length of the operation area.

[0552] (6-2-2) If the group type of the operation group is group type two:

[0553] Position the target buffer at the "current offset position of the target buffer".

[0554] Position the source buffer to the "head node offset address of the group" + temporary auxiliary length of the operation group, read the data of the operation group in the length of "tail node offset address of the group - head node offset address of the group" into the temporary buffer, and then write the data in the temporary buffer into the target buffer.

[0555] Update the current offset position of the target buffer to: the current offset position of the original target buffer + ("the offset address of the tail node of the group - the offset address of the head node of the group").

[0556] (6-2-3) If this operation group is the last operation group:

[0557] Set the target buffer length to: the current offset position of the target buffer.

[0558] (6-3) Iterate through the list of operation groups of the iterative operation type of the superimposed operation unit again, starting from the first element of the operation group list (index = 0) and continuing until the actual number of groups (group_number) elements. For each operation group:

[0559] (6-3-1) If the group type of the operation group is group type one: continue to traverse the next operation group.

[0560] (6-3-2) If the group type of the operation group is group type two:

[0561] (6-3-2-1) If the swap type (e.g., swap_type) of the group type binary structure of the operation group is odd: set the temporary pairing list to the odd pairing list of the group type binary structure of the operation group; otherwise, if the swap type (e.g., swap_type) of the group type binary structure of the operation group is even: set the temporary pairing list to the even pairing list of the group type binary structure of the operation group.

[0562] (6-3-2-2) Iterate through the list of temporary pairing regions, starting from the first element of the list (i.e., i = 0) at each index, up to the actual number of pairs (match_number - 1) in the file header structure. For each pairing region:

[0563] a) Locate the target buffer to the swap address one of the paired area elements, and read data of size "swap area length of the group type two-head structure of the operation group" into temporary buffer one.

[0564] b) Locate the target buffer to the swap address two of the paired area elements, and read data of size "swap area length of the group type two-head structure of the operation group" into temporary buffer two.

[0565] c) Locate the target buffer to the swap address one of the paired area elements, and then write the data in temporary buffer two. The length of the written data is "the swap area length of the group type two-head structure of the operation group".

[0566] d) Locate the target buffer to the swap address two of the paired area element, and then write the data in temporary buffer one. The length of the written data is "the swap area length of the group type two-head structure of the operation group".

[0567] Figure 5 The following example illustrates the implementation process of the file processing method described in this embodiment, using AI source files as an example.

[0568] like Figure 5 As shown, when protecting the AI ​​source model file, the AI ​​source model file is obtained, an empty AI protection model file is created, and a file header structure associated with the source file is constructed based on the random number of superposition operations and the operation type. The constructed model header structure is encrypted and written into the header of the AI ​​protection model file. The source model is read, and the AI ​​protection model file is constructed according to the information in the model header structure. The processed AI protection model file is then published for actual deployment. When the AI ​​source model file is to be used, the protection model header is verified, the original model is decoded from the protection model file, and stored in the target model buffer. In this embodiment, the entire AI model is not encrypted during the AI ​​model protection process. Instead, the AI ​​model is randomly destroyed, and the random destruction rules are encrypted and written into the AI ​​model header. Because the AI ​​model is randomly destroyed, the content destroyed is different each time for the same AI model, resulting in a different AI protection model after destruction, thereby maximizing the confidentiality and security of AI model protection. Furthermore, since the entire AI model is not encrypted, the protection of the AI ​​model is achieved while reducing the demand for computing resources. This is especially beneficial for devices with limited computing resources, as it improves the speed of deprotection before inference. The method in this embodiment is applicable to protecting any AI model, without restrictions on software and hardware environments or scenarios, and has strong versatility.

[0569] Figure 6 This is a block diagram illustrating an electronic device according to an embodiment of the present disclosure. (As shown) Figure 6As shown, this embodiment provides an electronic device 101, which includes a processor 1001 and a memory 1002. The memory 1002 is used to store computer programs. The processor 1001 is used to execute the computer programs stored in the memory 1002, so that the electronic device 101 performs the steps of the file processing method as described in Embodiment 1. Since the specific implementation process of each step of the file processing method has been described in detail in Embodiment 1, it will not be repeated here.

[0570] Processor 1001 is a CPU (Central Processing Unit). Memory 1002 is connected to processor 1001 via a system bus and communicates with it. Memory 1002 stores computer programs, and processor 1001 runs the computer programs to execute the file processing method described above. Memory 1002 may include random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device.

[0571] Furthermore, this embodiment also provides a computer-readable storage medium storing a computer program thereon, which, when executed by the processor 1001, implements the aforementioned file processing method. The file processing method has already been described in detail above and will not be repeated here.

[0572] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented using computer program-related hardware. The aforementioned computer program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0573] In summary, this application does not encrypt the entire source file (e.g., AI model file). Instead, it randomly corrupts the source file by constructing a file header structure, and then encrypts the random corruption rules and writes them into the source file header. Because the source file is randomly corrupted, the corrupted content is different each time, resulting in different protected files. This maximizes the confidentiality and security of the source file protection. Furthermore, since the entire source file is not encrypted, the demand for computing resources is reduced while protecting the source file, especially for devices with limited computing resources, thus improving the speed of deprotection before inference. The method of this application is applicable to protecting AI model files and various application documents, without limitations on software and hardware environments or scenarios, and has strong versatility. Therefore, this invention effectively overcomes the various shortcomings of existing technologies and has high industrial applicability.

[0574] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.

Claims

1. A file processing method, characterized in that, include: Create an empty first protected file for the source file; A file header structure associated with the source file is constructed based on the random number of superposition operations performed on the source file and the operation type. The file header structure is encrypted, and a second protected file is formed based on the encrypted file header structure and the first protected file; as well as The source file is processed according to the file header structure, and a third protected file is formed based on the processed source file and the second protected file. The construction of a file header structure associated with the source file based on the random number of superposition operations and the operation type includes: constructing a basic header and a list of superposition operation units, and performing a random number of superposition operations on the source file based on the list of superposition operation units; In each of the aforementioned overlay operations, a corresponding file header structure is constructed based on the randomly generated different operation types.

2. The file processing method according to claim 1, characterized in that, The file header structure consists of a base header of a preset size and a list of overlay operation units. The base header consists of a preset protection magic number, overlay mode, overlay point offset address list, overlay point offset address list length, actual overlay count, and overlay operation unit length. The overlay operation unit list is located after the base header of the preset size and consists of a list of overlay operation units with the number of overlay counts. The overlay operation unit consists of an iteration offset address list length, an iteration offset address list, an iteration operation type, an iteration operation type one-head structure, an iteration operation type two-head structure, and an iteration operation type three-head structure.

3. The file processing method according to claim 1, characterized in that, The operation type is an iterative operation type head structure, which consists of the number of actual operation areas and the operation area list. Each operation area in the operation area list consists of an offset address, a target offset address, and an operation length; the method for constructing the corresponding file header structure includes: A first set of random numbers and a second set of random numbers are randomly generated, wherein the first set of random numbers corresponds to the offset address of the operation area in the source file, and the second set of random numbers corresponds to the target offset address of the operation area in the source file; A third set of random numbers is inserted after the offset address of each of the operation areas as the operation length, wherein the starting position of the third set of random numbers is determined by the target offset address of the operation area.

4. The file processing method according to claim 1, characterized in that, The operation type is an iterative operation type two-head structure, which consists of exchange type, exchange operation mode, pairing mode, exchange area length, actual number of pairs, odd exchange offset address list, even exchange offset address list, odd pairing area list, and even pairing area list; the method for constructing the corresponding file header structure includes: Generate a preset number of random numbers as a list of swapped offset addresses; Based on the generated random numbers, the exchange offset addresses in the exchange offset address list are paired according to preset rules, and the exchange offset addresses are divided into multiple pairing areas, each pairing area consisting of two exchange addresses.

5. The document processing method according to claim 1, characterized in that, The operation type is an iterative operation type three-header structure, which consists of a grouping mode, an operation point offset address list, an actual number of groups, a group length type, and an operation group list; the method for constructing the corresponding file header structure includes: Generate a preset number of random numbers; The source files are grouped according to preset rules based on the generated random numbers, and the group type is randomly determined for each group of source files; Construct the file header structure for each group based on the group type.

6. The file processing method according to claim 1, characterized in that, The methods for encrypting the file header structure and forming a second protected file based on the encrypted file header structure and the first protected file include: When the size of the encrypted base header is equal to the size of the unencrypted base header, and the size of the encrypted overlay operation unit list is equal to the size of the unencrypted overlay operation unit list, the encrypted base header is written to the header of the empty protection file, and the encrypted overlay operation unit list is written to the current tail of the empty protection file. When the size of the encrypted base header is not equal to the size of the unencrypted base header, or the size of the encrypted superposition operation unit list is not equal to the size of the unencrypted superposition operation unit list, an auxiliary header of a preset size is constructed, and then the auxiliary header is written into the header of the empty protected file, and the encrypted base header is written into the current tail of the empty protected file. The auxiliary header includes a preset magic number, the size of the encrypted base header, and the size of the encrypted superposition operation unit list.

7. The document processing method according to claim 1, characterized in that, Forming a second protected file based on the encrypted file header structure and the first protected file includes: writing the encrypted file header structure into the header of the first protected file to form the second protected file.

8. The document processing method according to claim 1, characterized in that, Forming a third protected file based on the processed source file and the second protected file includes: writing the processed source file to the end of the second protected file to form the third protected file.

9. A file processing method, characterized in that, include: A protected file is received, the protected file including first information associated with an encrypted file header structure and second information associated with a processed source file obtained by processing the source file according to the file header structure, wherein the file header structure is constructed based on a random number of superposition operations and operation types performed on the source file, wherein a basic header and a list of superposition operation units are constructed, and the source file is subjected to a random number of superposition operations based on the list of superposition operation units, and in each superposition operation, a corresponding file header structure is constructed according to different randomly generated operation types; The first information of the protected file is verified based on the preset file header structure; as well as In response to the first information of the protected file being verified, the source file is derived based on the second information of the protected file.

10. A computer-readable storage medium storing computer-readable program instructions thereon, characterized in that, When the program instructions are executed, the file processing method according to any one of claims 1 to 8 or the file processing method according to claim 9 is used.

11. An electronic device, characterized in that, include: The memory is configured to store program instructions; as well as The processor is configured to execute the program instructions to implement the file processing method according to any one of claims 1 to 8 or the file processing method according to claim 9.