NC code integrity anomaly detection method based on fragile watermark

By embedding fragile watermarks in the NC code and performing detection, the problem of tampering and detection during NC code transmission is solved, and the accurate detection and positioning of NC code is achieved, ensuring processing accuracy and production safety.

CN119720136AActive Publication Date: 2025-03-28HARBIN INST OF TECH
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411761783.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-03
Publication Date
2025-03-28
Estimated Expiration
2044-12-03

AI Technical Summary

Technical Problem

The prior art is difficult to effectively detect and locate the tampering of NC codes during transmission, resulting in reduced processing accuracy and production safety risks.

Method used

The NC code integrity anomaly detection method based on fragile watermarks is adopted. By analyzing tool track coordinate data, grouped watermarks and global watermarks are generated and embedded, ensuring that the code has not been tampered with during transmission and precisely positioned when tampering is detected.

Benefits of technology

It realizes highly sensitive detection of NC code, can accurately judge and locate tamper, ensure the integrity and security of the code, does not affect the processing accuracy, and improves the system's attack resistance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119720136A_ABST
    Figure CN119720136A_ABST
Patent Text Reader

Abstract

The invention discloses an NC code integrity anomaly detection method based on a fragile watermark, and the method comprises the steps: firstly, through analyzing the geometric features of a tool path, combining with instruction information such as a G code and an M code in the code, employing a feature point detection algorithm to recognize a region with a large rotation angle or significant geometric change as a key position for watermark embedding; secondly, unique watermark information is generated and embedded into the selected redundant coordinate points, and it is ensured that the geometrical shape of the tool path is not affected; thirdly, after transmission is completed, watermark information is recovered from the embedded point through the watermark extraction technology and stored for subsequent comparison; finally, whether tampering occurs or not is detected by comparing the extracted watermark with the original watermark, if abnormity occurs, the tampering position is positioned, machining operation is stopped, and safety is ensured. According to the method, high-sensitivity detection of the NC code is realized through the fragile watermark technology, any tampering can be accurately judged, and the integrity and safety of the code are ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of numerical control, and relates to an NC code integrity detection method, and specifically to an NC code integrity anomaly detection method based on digital watermark technology. Background Art

[0002] With the continuous development of industrial automation and intelligent manufacturing, CNC technology occupies an increasingly important position in the manufacturing industry. As an important instruction for CNC machining, NC code directly determines the machining accuracy and product quality. However, in the actual machining process, NC code may encounter problems such as tampering, interference in data transmission, and errors in the code itself in various links from programming to transmission to execution. These problems will not only reduce the accuracy of machined parts, but may also cause serious production safety hazards. Therefore, how to ensure the integrity of NC code during transmission and execution has become a technical problem that needs to be solved urgently.

[0003] Some existing NC code detection methods often focus on syntax and logic errors in the code, but lack effective means to detect tampering during code transmission. Traditional integrity verification methods have problems such as inability to accurately detect tampering locations and low detection accuracy when dealing with complex CNC machining environments. To this end, the study of NC code integrity detection methods based on digital watermarks can effectively improve the detectability and positioning accuracy of code tampering, ensure that the code has not been tampered with during transmission, and at the same time do not affect the execution accuracy of machining tasks. Summary of the invention

[0004] In view of the fact that NC codes may be tampered with during transmission to CNC machine tools, the traditional NC code transmission process lacks effective anti-tampering means, and the integrity of the code cannot be detected in real time. There is a problem that tampering cannot be discovered in time, which affects the processing quality and production safety. The present invention provides an NC code integrity anomaly detection method based on fragile watermarks, which is used to protect the NC code from possible tampering during transmission. The present invention analyzes the characteristics of tool trajectory coordinate data in NC codes, and combines geometric features and special codes to propose a program segment division algorithm to achieve reasonable grouping of NC codes; the fragile watermark technology is used to embed watermark information into the NC code, so that the code can be detected and located in time when it is tampered; the watermark embedding process maintains invisibility by not changing the geometric shape of the tool trajectory, while ensuring the reversibility of the embedded watermark, that is, the original NC code can be completely restored without being attacked.

[0005] The objective of the present invention is achieved through the following technical solutions:

[0006] A method for detecting anomaly in NC code integrity based on fragile watermarks comprises the following steps:

[0007] Step S1: Analyze the NC code tool trajectory coordinate data, extract its geometric characteristics and instruction information, and identify the characteristic trajectory area;

[0008] Step S2: Based on the analysis of tool trajectory data, the NC code is divided into multiple program segments using a segmentation algorithm based on geometric features and instruction information. Each program segment consists of a group of trajectory data with similar characteristics or functions. These program segments are the basic units for watermark generation and embedding, including functional instruction segments and trajectory data segments.

[0009] Step S3: Generate a group watermark and a global watermark according to the characteristics of each program segment and the key used to generate the hash value of each program segment, and combine the watermark information with the trajectory data;

[0010] Step S4: applying watermark embedding technology to embed the watermark into the tool path coordinates of the NC code to ensure that the geometric shape remains unchanged;

[0011] Step S5: After the NC code is transmitted, the embedded watermark is extracted using a watermark extraction algorithm and compared with the original watermark;

[0012] Step S6: judging whether the NC code has been tampered with according to the comparison result, and if not, performing normal processing;

[0013] Step S7: If tampering is detected, use a tampering location algorithm to locate the abnormal position and analyze the tampering type;

[0014] Step S8: Output the tampering positioning result and prompt the operator to take measures.

[0015] Compared with the prior art, the present invention has the following advantages:

[0016] 1. The present invention uses fragile watermark technology to achieve highly sensitive detection of NC codes, and can make accurate judgments on any tampering (such as insertion, deletion or modification) to ensure the integrity and security of the code. At the same time, combined with group watermarks and global watermarks, it can accurately locate the specific program segment or trajectory point that has been tampered with, achieve fine-grained abnormal location, and greatly facilitate the rapid troubleshooting and repair of problems.

[0017] 2. The watermark embedding design of the present invention is highly invisible and will not change the geometry of the tool trajectory. It will not affect the processing accuracy and is difficult to be detected, thereby improving security and concealment.

[0018] 3. The present invention has good reversibility. In the absence of tampering, the watermark can be completely removed and the original NC code data can be restored, ensuring that the processing accuracy is absolutely protected.

[0019] 4. In terms of security, the present invention encrypts the watermark with a key, so that even if an attacker masters the embedding algorithm, he cannot forge a valid watermark without obtaining the key, which greatly improves the system's anti-attack capability.

[0020] 5. The present invention is flexible in design and can adapt to NC codes and tool trajectory characteristics of different complexities through program segment division and multiple embedding strategies, and can be widely used in various processing scenarios.

[0021] 6. The present invention can not only detect tampering, but also analyze the type of tampering (such as insertion, deletion or modification), providing a clear basis for problem tracing and repair.

[0022] 7. The present invention supports real-time detection, and can quickly discover problems and take measures after the NC code transmission is completed, thereby fully ensuring processing safety and efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 It is a flow chart of the NC code integrity anomaly detection method based on fragile watermark;

[0024] Figure 2 It is a specific flow chart of the NC code integrity anomaly detection method based on fragile watermark;

[0025] Figure 3 Comparison of trajectory shapes before and after adding redundant trajectory points;

[0026] Figure 4 To delete the entire line of NC code;

[0027] Figure 5 This is the NC code before the attack;

[0028] Figure 6 This is the integrity test result of the code receiving end in attack test 2;

[0029] Figure 7 is the sequence number shift detection algorithm;

[0030] Figure 8 This is the detection result after repair using the sequence number shift detection algorithm;

[0031] Fig. 9 This is the integrity test result of the receiver of attack test 3 code;

[0032] Fig.10 This is the result of the first use of sequence number shift detection;

[0033] Fig.11 The result of the second sequence number shift test;

[0034] Fig.12This is the NC code before the attack;

[0035] Fig.13 Tamper the results for attack test 4;

[0036] Fig.14 The integrity test result of the receiving end of attack test 4 code;

[0037] Fig.15 The results of attack test 4 were analyzed using the sequence number shift detection method. DETAILED DESCRIPTION

[0038] The technical solution of the present invention is further described below in conjunction with the accompanying drawings, but is not limited thereto. Any modification or equivalent replacement of the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention should be included in the protection scope of the present invention.

[0039] The present invention provides a method for detecting NC code integrity anomalies based on fragile watermarks, such as Figure 1 As shown in the figure, first, by analyzing the geometric features of the tool trajectory and combining the G code, M code and other instruction information in the code, the feature point detection algorithm is used to identify the area with large corners or significant geometric changes as the key position for watermark embedding; then, a unique watermark information is generated and embedded into the selected redundant coordinate points to ensure that the geometric shape of the tool trajectory is not affected; then, after the transmission is completed, the watermark information is restored from the embedded point through the watermark extraction technology and saved for subsequent comparison; finally, by comparing the extracted watermark with the original watermark, it is detected whether tampering has occurred. If there is any abnormality, the tampering position is located and the processing operation is stopped to ensure safety. Figure 2 As shown, the specific steps are as follows:

[0040] Step S1: Analyze the NC code tool trajectory coordinate data, extract its geometric characteristics and instruction information, and identify the characteristic trajectory area. The specific steps are as follows:

[0041] Step S11: Perform detailed analysis on the tool path data in the NC code to identify its key characteristics.

[0042] Step S12: By extracting the geometric characteristics of the tool movement, such as straight segments, curve segments and corners, the characteristic trajectory areas with significant characteristics in the NC code are identified. The characteristic trajectory areas refer to the key trajectory points or areas extracted from the NC code based on geometric characteristics and instruction information for watermark embedding and detection. These areas include trajectory positions with special geometric shapes, such as large angles or rapid change points.

[0043] Step S13: extracting the functional instruction information (such as G code and M code) in the code to help divide different program segments, providing a clear segmentation basis for subsequent watermark embedding.

[0044] NC code tool path data has the following characteristics:

[0045] 1) The entire NC code production process is complex, with high production costs in manpower and material resources, and high requirements for availability and precision. Once the precision does not meet the requirements, the processed parts are likely to lose their availability.

[0046] 2) The storage and program operation of the tool path data of the NC code are linear and orderly. The program part of the NC code is executed in a linear order. The decoder reads and decodes each line of code and transmits the data to the controller to control the transmission device of the machine tool to realize processing.

[0047] 3) The tool path data of the NC code has low data redundancy. The spatial relationship characteristics of the tool path points have a certain degree of complexity. The structure of the tool path data points is compact and the number of redundant bits is low, resulting in low data redundancy.

[0048] Based on the above three characteristics, embedding watermarks by modifying the coordinate data of trajectory points may distort the trajectory shape and easily attract the attention of attackers. Figure 3 As shown in the figure, P1 and P2 are added redundant trajectory points. Adding watermark trajectory points similar to P1 and P2 to the two tool trajectory points will not affect the shape of the tool trajectory. At the same time, the movement of data point P1 on the line segment where D2 and D3 are located will not affect the shape of the tool trajectory, making the watermark highly invisible and not easily noticed by attackers.

[0049] Step S2: Based on the analysis of the tool trajectory data, the NC code is divided into multiple program segments using a segmentation algorithm based on geometric features and instruction information. Each program segment consists of a group of trajectory data with similar characteristics, usually including a functional instruction segment and a trajectory data segment. The functional instruction segment contains specific operation instructions, such as G00 rapid positioning and G01 linear interpolation; the trajectory data segment represents the specific motion path of the tool. The divided program segments can ensure the flexibility of watermark embedding and facilitate the precise positioning of the tampered position during detection.

[0050] In this step, in order to realize the division of NC code program segments, set f d To realize the division method; in order to facilitate the processing of the data of each group, set f I The NC code program segment grouping data is converted into the standard program segment grouping data form, which contains all the information completely restored to the original NC code; in order to achieve the purpose of generating watermarks, set f h Generate group G according to key K1 i The hash value of the generated hash value is then extracted according to the key K2, and finally the fixed bit length H is obtained.i , as shown in formula (1):

[0051]

[0052] Where, F is the original NC code content to be divided; P i is the i-th grouping of the NC code program segment F after using the partitioning algorithm; N is the partitioning result, with a total of N groups; G i is the standardized i-th group code; K1 is and G i K2 is the position of extracting a fixed bit from the generated hash value according to the key; H i It is the watermark information generated according to the hash value and K2.

[0053] Step S3: Generate group watermarks and global watermarks based on the characteristics of each program segment and the key used to generate the hash value of each program segment, and combine the watermark information with the trajectory data. The specific steps are as follows:

[0054] After the NC code is divided, an independent group watermark is generated for each program segment to ensure the integrity of each code segment. In addition, a global watermark is generated for overall integrity verification, where: the watermark is generated based on the hash value of each group, and the hash value is encrypted using a symmetric encryption key to increase security. This combination of group watermarks and global watermarks can provide double protection when tampering occurs, not only detecting local tampering, but also identifying global anomalies.

[0055] Step S4: Apply watermark embedding technology to embed the watermark generated in step S3 into the key position of the tool trajectory in the NC code, ensuring that the watermark is embedded without changing the geometric shape. The selection of embedding points is based on the characteristics of the trajectory data, such as adding watermarks between adjacent trajectory points, or modifying the least significant bit of a specific trajectory point to ensure the concealment of the watermark. Through multiple embedding strategies, the watermark embedding is difficult to be discovered during the processing process, thereby protecting the integrity of the NC code.

[0056] In this step, let f e is the watermark embedding method, which selects the watermark H according to the key K1 i It is embedded into the position of the trajectory data to prevent the illegal extraction of watermark information and the leakage of the original NC code, thereby enhancing the security of the watermark information, as shown in formula (2):

[0057] f e :D g ×K1×H i →D g +D e (2)

[0058] Where D g is the original NC code; K1 is used to determine the location embedded in the trajectory data; when K1 is used to generate a hash value, it is represented by K 1-gen ; When K1 is used to locate and extract watermark information, it is expressed as K 1-extract ;D e is the part that is different from the original NC code after embedding the watermark, that is, the embedded trajectory data point. g +D e This is the final NC code containing the watermark.

[0059] Step S5: After the NC code is transmitted, the embedded watermark is extracted using a watermark extraction algorithm and compared with the original watermark. The specific steps are as follows:

[0060] When the NC code is transmitted, the embedded watermark information is extracted from the receiving end and compared with the original watermark: first, the group watermark is extracted and its consistency is verified segment by segment, and then the global watermark is extracted for overall comparison. By comparing the extracted watermark with the original watermark, it is possible to effectively determine whether the NC code has been tampered with during transmission. If the extracted watermark is exactly the same as the original watermark, the code is considered complete; otherwise, the anomaly detection process is entered.

[0061] Step S6: Based on the comparison result, determine whether the NC code has been tampered with. If not, perform normal processing. The specific steps are as follows:

[0062] The integrity of the NC code can be determined by extracting and comparing watermarks. If all watermarks are consistent, it means that the code has not been tampered with and enters the normal processing process; if the watermarks are inconsistent, it means that the code may have been tampered with. At this time, the system suspends the execution of the NC code and enters the next step of tampering detection and positioning process to prevent incomplete codes from affecting production safety.

[0063] In this step, let f1 be the NC code division algorithm, divide the received NC code and standardize the grouping, let f h1 To extract the watermark information H according to the key K1 r The method is as follows: let f2 realize the extraction of the original NC code, let f3 realize the restored NC code to generate a hash value according to the key K1, then extract a fixed bit from the generated hash value according to the key K2, and finally compare the extracted hash value with H r By comparison, if they are exactly the same, it means that no tampering has occurred, otherwise tampering has occurred, as shown in formula (3):

[0064]

[0065] Where D r G is the received NC code; riis the i-th group after division; H r is the extracted watermark information; D is the restored NC code; s is the detection output result, which is in the form of Boolean value, where 1 means it has been tampered with and needs to be detected for abnormality, and 0 means it has not been tampered with and can be processed normally.

[0066] Step S7: If tampering is detected, use the tampering location algorithm to locate the abnormal position and analyze the tampering type. The specific steps are as follows:

[0067] After code tampering is detected, the tampering location algorithm is used to accurately locate the abnormal position. The core principle of the algorithm is to detect the integrity of the watermark segment by segment based on the group watermark, and quickly determine the location of the tampered group by comparing the group hash value. Then, combined with the overall consistency of the global watermark, it is further determined whether the tampering involves the functional instruction segment or the trajectory data segment, and the specific tampering type is distinguished. First, the watermark is extracted from each group and compared with the original watermark to mark the abnormal group. Then, the trajectory points or functional instructions are verified one by one in the abnormal group to distinguish the tampering type (such as deletion, insertion or modification). Finally, the specific tampering location is marked and a detailed detection report is generated based on the location information of the watermark embedding point. Combining the sensitivity of the group watermark and the overall consistency of the global watermark, the algorithm can improve the positioning accuracy to the instruction level or trajectory point level within the group. By comparing the watermark segment by segment, the specific tampered segment is determined, and further analysis is performed on whether the functional instruction segment or the trajectory data segment is abnormal, and the type of tampering, such as deletion, insertion or modification, is recorded in detail. This step ensures the accuracy of positioning, allowing operators to clearly understand the specific location and scope of tampering.

[0068] Step S8: Output the tampering location result and prompt the operator to take measures. The specific steps are as follows:

[0069] The results of the tampering detection are fed back to the operator, including the integrity status of the NC code and detailed tampering information. If the code is intact, the processing continues; if tampering is detected, the system prompts the operator to suspend processing and take corresponding treatment measures, such as regenerating the NC code or retransmitting reliable code. Through this process, the NC code integrity detection method effectively ensures the safety and reliability of CNC processing.

[0070] Example:

[0071] Attack Test 1: When the attacker only deletes the entire line of trajectory data in group G5, the entire line of code with sequence number N1426 is deleted, such as Figure 4 shown.

[0072] Integrity detection results at the receiving end and analysis of tampering possibility: When performing group watermark detection at the receiving end, it was detected that only the fifth group G5 had an abnormality, and no abnormality occurred in other groups. Groups G4 and G6 contained the special code segments above and below the special code segments of group G5, and no abnormality occurred in groups G4 and G6, which shows that the abnormality can only occur in the trajectory data segment of group G5. When the data of a single trajectory point of G5 is deleted, including the sequence number of the row, if the sequence number is not adjusted, an interval error occurs, and the fixed interval becomes a multiple of the original. When the number of deleted rows is N, the fixed interval is T, and the fixed interval becomes T*(N+1).

[0073] Analysis results: The trajectory data segment of group G5 was deleted abnormally. The fixed interval of the code was 2, and the interval between N1428 and N1424 was changed to 4, and N=1 lines of code were deleted.

[0074] Attack Test 2: NC code before the attack Figure 5 As shown, the attacker performed a deletion attack on the trajectory data of group G5, deleted 3 lines of code, and globally updated the sequence number.

[0075] The integrity test result of the code receiving end: It is found that the G5 group and all subsequent groups are abnormal, such as Figure 6 As shown, the extracted global watermarks are abnormal.

[0076] Analysis of tampering possibility: When the attacker deletes the data of multiple track points in group G5, including the sequence number of the row, and readjusts the sequence number, the sequence numbers of all groups after G5 are tampered with. Since the sequence number also participates in the hash operation, all watermark verifications are invalid. The attacker may have deleted or inserted the code and readjusted the sequence number. The present invention uses a sequence number shift detection algorithm to solve this problem. The process is as follows: Figure 7 As shown, by increasing or decreasing the global sequence number of the abnormal group to find a possible legal sequence number, the sequence number anomaly can be recovered, which is conducive to the advancement of tampering positioning work.

[0077] When the sequence number shift algorithm is used for trial, the sequence numbers of each group after G5 are incremented. Each time the sequence number is incremented, the group after G5 is checked for integrity. If only the G5 check fails, it means that the attacker has deleted the trajectory data segment of the G5 group. If the sequence number increment is n intervals, it means that the number of deleted vertices is n. When the sequence number increment is 3, the sixth group and all subsequent groups have returned to normal. Figure 8 shown.

[0078] Analysis results: The G5 group trajectory data segment was attacked by deletion, and the marker number was 3, indicating that 3 lines of code were deleted.

[0079] Attack Test 3: The attacker deletes both the G5 group and the G 12 The code of the trajectory data segment of the group is reset and the sequence number is readjusted.

[0080] Code receiving end integrity test results: When receiving abnormal code at the receiving end, it is found that the G5 group and its subsequent groups are abnormal, such as Fig. 9 shown.

[0081] Analysis of tampering possibility: Using a sequence number shift detection method, it is found that G6 to G 11 The group has returned to normal, and in G 12 There are still exceptions in the following places, such as Fig.10 As shown, G 12 There is a possibility that an attacker could delete or insert code.

[0082] For G 12 The following grouping uses the sequence number shift detection method to further judge, and adopts the incremental shift method. The results are as follows Fig.11 As shown, only G5 group has G 12 The group watermark is abnormal. After extracting the global watermark, the test result shows that the global special code segment is normal, but the global trajectory data segment is abnormal. Therefore, it can be judged that the G5 group and G 12 The tool path data of the group are all deleted. If other situations occur, such as G 12 If an abnormality occurs in a subsequent group, the sequence number shift detection method is continued for analysis, which will not be described in detail here.

[0083] Analysis results: G5 group and G 12 The trajectory data segments of the group were all deleted.

[0084] Attack Test 4: NC code before the attack Fig.12 shown.

[0085] The attacker deletes points D3 (N797), D4, and D5 of group G5, and after deletion, readjusts the sequence number. The angle at point D2 is greater than the threshold of 90 degrees. The tampered result is as follows: Fig.13 shown.

[0086] Code receiving end integrity test results: When receiving abnormal code at the receiving end, it is found that the G5 group and its subsequent groups are abnormal, such as Fig.14 shown.

[0087] Analysis of tampering possibility: The attacker's deletion of trajectory points will cause errors in grouping during the watermark extraction phase. In this test, the corner threshold is set to 90 degrees and the corner increment point threshold is set to 2. Therefore, the original trajectory D2 (N796) is not considered a special code segment. After deleting points D3, D4, and D5, the corner threshold of point D2 is greater than 90 degrees, causing D2 to become a special code segment. The original G5 group is the group that was attacked by the deletion attack. After tampering, when the receiving end detects it, the original G5 group is divided into new Group and group, and the tampered trajectory data segment of the original G5 group is regarded as the new The following special code snippet of the group and The special code segment above is at position D2 (N796). Because one more watermark is extracted based on deleting three points, All subsequent groups of the group had abnormal sequence numbers. The sequence number shift detection method was first used for analysis. The results are as follows Fig.15 As shown in the figure, after extracting the global watermark and performing integrity check, abnormalities were found.

[0088] Analysis results: Both the special code segment and the global watermark of the trajectory data will be abnormal, so we can only locate The following special code snippet of the group, Trajectory data segment, Group the special code snippet above, The trajectory data segment is essentially the positioning result of the original G5 group trajectory data segment. Due to an exception in the global special code segment, in addition to the new Group and All groups other than the group are normal, which means that the abnormal location of the special code segment can only occur in The following special code snippet of the group and The above special code segments are combined, and these two special code segments are the same special code segment, so the exception occurs at D2 (N796).

Claims

1. A method for detecting NC code integrity anomalies based on fragile watermarks, characterized in that The method comprises the following steps: Step S1: Analyze the NC code tool trajectory coordinate data, extract its geometric characteristics and instruction information, and identify the characteristic trajectory area; Step S2: Based on the analysis of the tool trajectory data, the NC code is divided into a plurality of program segments using a segmentation algorithm based on geometric features and instruction information, each program segment consisting of a group of trajectory data with similar characteristics or functions, including a functional instruction segment and a trajectory data segment; Step S3: Generate a group watermark and a global watermark according to the characteristics of each program segment and the key used to generate the hash value of each program segment, and combine the watermark information with the trajectory data; Step S4: applying watermark embedding technology to embed the watermark into the tool path coordinates of the NC code to ensure that the geometric shape remains unchanged; Step S5: After the NC code is transmitted, the embedded watermark is extracted using a watermark extraction algorithm and compared with the original watermark; Step S6: judging whether the NC code has been tampered with according to the comparison result, and if not, performing normal processing; Step S7: If tampering is detected, use a tampering location algorithm to locate the abnormal position and analyze the tampering type; Step S8: Output the tampering positioning result and prompt the operator to take measures.

2. The NC code integrity anomaly detection method based on fragile watermark according to claim 1 is characterized in that The specific steps of step S1 are as follows: Step S11: Detailed analysis of the tool path data in the NC code to identify its key characteristics; Step S12: identifying a characteristic trajectory region with significant characteristics in the NC code by extracting the geometric characteristics of the tool motion; Step S13: extracting the functional instruction information in the code to help divide different program segments, providing a clear segmentation basis for subsequent watermark embedding.

3. The NC code integrity anomaly detection method based on fragile watermark according to claim 1 is characterized in that In step S2, in order to realize the division of NC code program segments, it is assumed that f d To realize the division method; in order to facilitate the processing of the data of each group, set f I The NC code program segment grouping data is converted into the standard program segment grouping data form, which contains all the information completely restored to the original NC code; in order to achieve the purpose of generating watermarks, set f h Generate group G according to key K1 i The hash value of the generated hash value is then extracted according to the key K2, and finally the fixed bit length H is obtained. i , as shown in formula (1): Where, F is the original NC code content to be divided; P i is the i-th grouping of the NC code program segment F after using the partitioning algorithm; N is the partitioning result, with a total of N groups; G i is the standardized i-th group code; K1 is and G i K2 is the position of extracting a fixed bit from the generated hash value according to the key; H i is the watermark information generated based on the hash value and K2.

4. The NC code integrity anomaly detection method based on fragile watermark according to claim 1 is characterized in that The specific steps of step S3 are as follows: After completing the NC code division, an independent group watermark is generated for each program segment to ensure the integrity of each code segment. In addition, a global watermark is generated for overall integrity verification, where: the watermark is generated based on the hash value of each group, and the hash value is encrypted using a symmetric encryption key to increase security.

5. The NC code integrity anomaly detection method based on fragile watermark according to claim 1 is characterized in that In step S4, let f e is the watermark embedding method, which selects the watermark H according to the key K1 i It is embedded into the position of the trajectory data to prevent the illegal extraction of watermark information and the leakage of the original NC code, thereby enhancing the security of the watermark information, as shown in formula (2): f e :D g ×K1×H i →D g +D e (2) Where D g is the original NC code; K1 is used to determine the position embedded in the trajectory data; D e is the part that is different from the original NC code after embedding the watermark, that is, the embedded trajectory data point, D g +D e This is the final NC code containing the watermark.

6. The NC code integrity anomaly detection method based on fragile watermark according to claim 1 is characterized in that The specific steps of step S5 are as follows: When the NC code is transmitted, the embedded watermark information is extracted from the receiving end and compared with the original watermark: first, the group watermark is extracted and its consistency is verified segment by segment, and then the global watermark is extracted for overall comparison.

7. The NC code integrity anomaly detection method based on fragile watermark according to claim 1 is characterized in that The specific steps of step S6 are as follows: The integrity of the NC code is determined by extracting and comparing watermarks. If all watermarks are consistent, it means that the code has not been tampered with and the normal processing flow is entered. If the watermarks are inconsistent, it means that the code may have been tampered with. At this time, the system suspends the execution of the NC code and enters the next step of tampering detection and positioning process to prevent incomplete code from affecting production safety.

8. The NC code integrity anomaly detection method based on fragile watermark according to claim 1 or 7, characterized in that In step S6, let f1 be the NC code division algorithm, divide the received NC code and standardize the groups, let f h1 To extract the watermark information H according to the key K1 r The method is as follows: let f2 realize the extraction of the original NC code, let f3 realize the restored NC code to generate a hash value according to the key K1, then extract a fixed bit from the generated hash value according to the key K2, and finally compare the extracted hash value with H r By comparison, if they are exactly the same, it means that no tampering has occurred, otherwise tampering has occurred, as shown in formula (3): Where D r G is the received NC code; ri is the i-th group after division; H r is the extracted watermark information; D is the restored NC code; s is the detection output result, which is in the form of Boolean value, where 1 means it has been tampered with and needs to be detected for abnormality, and 0 means it has not been tampered with and can be processed normally.

9. The NC code integrity anomaly detection method based on fragile watermark according to claim 1 is characterized in that The specific steps of step S7 are as follows: After detecting code tampering, the tampering location algorithm is used to accurately locate the abnormal position. By comparing the watermarks section by section, the specific tampered section is determined. Further analysis is performed on whether the abnormality occurs in the functional instruction section or the trajectory data section, and the type of tampering is recorded in detail.

10. The NC code integrity anomaly detection method based on fragile watermark according to claim 1 is characterized in that The specific steps of step S8 are as follows: The results of the tampering detection are fed back to the operator, including the integrity status of the NC code and detailed tampering information. If the code is intact, processing continues; if tampering is detected, the system prompts the operator to suspend processing and take appropriate measures to regenerate the NC code or retransmit reliable code.

Citation Information

Patent Citations

  • Vector map integrity authentication method for tampered primitive set positioning

    CN107154011A

  • Vector map data fragile watermarking method for positioning tampered entity group

    CN112446814A

  • Device for embedding digital watermark and its program

    JP2004023184A

  • Method and apparatus of inserting / extracting fragile digital watermarks and apparatus for using thereof

    KR101145110B1