CN113934989A - G-code file authentication and recovery method based on self-embedded watermark - Google Patents
G-code file authentication and recovery method based on self-embedded watermark Download PDFInfo
- Publication number
- CN113934989A CN113934989A CN202111109077.9A CN202111109077A CN113934989A CN 113934989 A CN113934989 A CN 113934989A CN 202111109077 A CN202111109077 A CN 202111109077A CN 113934989 A CN113934989 A CN 113934989A
- Authority
- CN
- China
- Prior art keywords
- code
- watermark
- authentication
- code file
- recovery
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000011084 recovery Methods 0.000 title claims abstract description 70
- 238000000034 method Methods 0.000 title claims abstract description 55
- 238000013507 mapping Methods 0.000 claims abstract description 10
- 230000036961 partial effect Effects 0.000 claims abstract description 4
- 230000000694 effects Effects 0.000 claims description 9
- 241001505100 Succisa pratensis Species 0.000 claims description 3
- 238000010146 3D printing Methods 0.000 abstract description 18
- 230000008569 process Effects 0.000 abstract description 17
- 238000001514 detection method Methods 0.000 description 10
- 230000006870 function Effects 0.000 description 10
- 238000007639 printing Methods 0.000 description 8
- 238000002474 experimental method Methods 0.000 description 7
- 238000011960 computer-aided design Methods 0.000 description 6
- 230000006872 improvement Effects 0.000 description 3
- 238000004519 manufacturing process Methods 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000012544 monitoring process Methods 0.000 description 3
- 238000012360 testing method Methods 0.000 description 3
- 241000984642 Cura Species 0.000 description 2
- 239000000654 additive Substances 0.000 description 2
- 230000000996 additive effect Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000001125 extrusion Methods 0.000 description 2
- MKIMSXGUTQTKJU-UHFFFAOYSA-N Propamocarb hydrochloride Chemical compound [Cl-].CCCOC(=O)NCCC[NH+](C)C MKIMSXGUTQTKJU-UHFFFAOYSA-N 0.000 description 1
- 230000002411 adverse Effects 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 230000001186 cumulative effect Effects 0.000 description 1
- 230000002950 deficient Effects 0.000 description 1
- 230000008021 deposition Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000036541 health Effects 0.000 description 1
- 238000010438 heat treatment Methods 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 230000002829 reductive effect Effects 0.000 description 1
- 230000002441 reversible effect Effects 0.000 description 1
- 238000012549 training Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/10—Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
- G06F21/16—Program or content traceability, e.g. by watermarking
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Computer Security & Cryptography (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Health & Medical Sciences (AREA)
- Bioethics (AREA)
- Health & Medical Sciences (AREA)
- Multimedia (AREA)
- Technology Law (AREA)
- Editing Of Facsimile Originals (AREA)
- Image Processing (AREA)
Abstract
The invention discloses a G-code file authentication and recovery method based on self-embedded watermarks, which comprises the following steps: dividing the command lines of G0 and G1 into code blocks and scrambling; dividing each scrambled code block into two parts, wherein X and Y coordinates in the part I are used for generating an authentication watermark and a recovery watermark, and X and Y coordinates in the part II are used for bearing the recovery watermark; converting X and Y into binary; generating an authentication watermark based on the FNV hash function, and embedding the authentication watermark into the code block; embedding a recovery watermark in the mapping block; then converting the X and Y coordinates into decimal representation; when a 3D printer receives a G-code file, firstly checking whether the G-code file is tampered; if no tampering is detected, recovering distortion caused by the authentication watermark according to the recovery watermark; if the G-code file is tampered, partial recovery is performed using the recovery watermark and the geometric information of the adjacent code blocks. The invention can improve the safety of using the G-code file in the 3D printing process.
Description
Technical Field
The invention belongs to the technical field of 3D printing, and particularly relates to a G-code file authentication and recovery method based on self-embedded watermarks.
Background
3D printing, also known as Additive Manufacturing (AM), is an important technology for industry 4.0. It has been widely used in many key industries such as automotive manufacturing, health care, aviation, construction, etc. Therefore, the quality and integrity of the 3D printed product is crucial to the safety and reliability of its application field.
There are many types of 3D printing techniques, and most desktop 3D printers are based on Fused Deposition Modeling (FDM). We will take an FDM 3D printer as an example to illustrate the 3D printing process, as shown in fig. 1. First, a user creates a digital 3D object in stl (stereolithrography) format using CAD software. The STL file is then converted to a machine language, i.e., a G-code file, by slicing software such as Cura or Slic3 r. In this step, the 3D object appears to have been cut into layers, but it is actually planning a printed path. In addition, many other printing parameters are also set by the slicing software, such as heating temperature, fan speed, extrusion rate, etc. Finally, the G-code file is sent to a 3D printer containing plastic consumables and heated nozzles. The plastic consumables are melted by the nozzle and placed on the platform at the precise location specified by the G-code. After one layer is completed, the platform moves downward and the process is repeated until the part is printed.
G-code is the most widely used Computer Numerical Control (CNC) programming language in subtractive and additive manufacturing. G-code stands for "geometric code". In short, the G-code indicates the location of the tool movement, the speed of the movement, and the path followed. In the case of 3D printing, the G-code file includes the aforementioned printing parameters and instructions to control nozzle movement. An example of a G-code file is shown in fig. 2. G0 and G1 are the two codes most commonly used in 3D printing. More specifically, G0 commands the nozzle to be moved from the current position to the coordinates specified by X, Y and Z values at maximum travel speed without extrusion. G1 shows the straight line to the specified position and the extruded length is determined by the E value, which represents the cumulative amount of filament that has been extruded so far. In addition, the value F in mm/min represents the speed of nozzle movement.
Disturbingly, with the advent of more and more web service-based 3D printers, 3D printing is facing many security challenges and network domain-physical domain vulnerabilities. For example, an attacker can access a PC connected to a 3D printer and then make various attacks. It has been demonstrated that attackers can create defective parts by adding malicious filled voids in a Computer Aided Design (CAD) file. At the same time, printing settings, such as high temperature heaters, can be manipulated, causing a physical hazard, similar to Stuxnet. In addition, if an attacker successfully applies a man-in-the-middle attack between PCs, the attacker can maliciously tamper with the G-code file transmitted from the PC to the 3D printer, which functions to control the movement of the print head. Tampering with a G-code file is less noticeable than tampering with a CAD file, because once the slicing is complete, people generally pay less attention to the G-code file. Furthermore, the intellectual property of the 3D model to be printed may also be stolen by attackers.
3D security issues are receiving increasing attention from academia, especially 3D printing. Gao et al (Y.Gao, B.Li, W.Wang, W.xu, C.Zhou, and Z.jin, "Watching and safety training your 3D printer: on line process monitoring acquisition cell-physical attcks," ProEdges of the ACM on Interactive, Mobile, Wearable and Ubiquitous Technologies, vol.2, No.3, pp.1-27,2018.) proposed an online process monitoring method to resist adverse modifications of key print attributes specified by 3D printer firmware. This method monitors the printing process with multiple sensors, with the ability to reconstruct the fill path and print speed, analyze layer thickness, and estimate fan speed. Attacks can be detected by comparing the results obtained by the monitoring system with the original print settings. Recently, Rais et al (M.H.Rais, Y.Li, and I.Ahmed, "spatial deployed G-code modeling for secure FDM-based 3D printing," in Proceedings of the ACM/IEEE 12thInternational Conference on Cyber-Physical Systems,2021, pp.177-186) proposed a framework for checking the integrity of 3D printing processes, using G-codes as ground truth to validate acquired sensor data to determine if a printing process is under attack. Clearly, this framework is based on the assumption that the attacker does not contain G-code. Furthermore, both of the above methods have a limitation in that an attack can be detected only after printing is completed, and the occurrence of the involved printing process cannot be prevented in advance.
To overcome these limitations, authentication of the G-code file before printing is very important because the G-code file contains machine-readable command lines, which are the final input to the 3D printer.
In terms of authentication methods, fragile watermarks are widely used for authentication of digital images, audio, video, 3D objects, and other digital files. For example, self-embedding fragile watermarking algorithms for digital images have the ability to detect, locate and recover tampered pixels in the image. There are some classical watermarking methods for 3D CAD object authentication, but they are not suitable for 3D printed scenes because the G-code file obtained after slicing a CAD object is very different from the structure of the CAD object.
Disclosure of Invention
The invention provides a G-code file authentication and recovery method based on self-embedded watermarks, aiming at the problem that the existing classical watermark method is not suitable for 3D printing scenes.
In order to achieve the purpose, the invention adopts the following technical scheme:
a G-code file authentication and recovery method based on self-embedded watermarks comprises the following steps:
Further, the step 3 comprises:
translating all the numbers of the X and Y coordinates to the left by three digits to obtain a decimal integer; then, the decimal integer is converted into a binary integer with the length of p, and the binary integer is recorded asAndwhere i 1, 2.., N, where N is the total number of G0 and G1 command lines in the G-code file.
Further, the step 4 comprises:
for the scrambled code blockThe part(s) of (1) is,n is the number of code lines contained in each code block; in which the binary representation of the X coordinate is denoted byWhileThe highest p-6 bit information is input into the FNV hash function and a 6-bit authentication watermark is generatedThen, after that,the lowest 6 bits are replaced byTo obtainThe above steps are equally applied to the Y coordinate.
Further, the step 5 comprises:
code blockThe recovery watermark is bit information of a part I of the code block before embedding the authentication watermarkAndcode blockIs mapped to a blockX and Y coordinates in part IIIs the lowest ofBit replacement by code blockRecovering the watermark; the recovered watermark of the last code block in the scrambled sequence is embedded in the first code block of the sequence.
Further, the step 7 includes:
dividing the command lines of G0 and G1 in the received G-code file into code blocks and scrambling by using a function P; dividing each code block after scrambling into two parts, wherein part I is a first command line, and part II is the rest command line; obtaining binary representation of X and Y coordinates of each code block; computing authentication watermarks for each code blockIf it is notAre respectively connected withIs the same, then the code block is consideredNot tampered, otherwise, the card is considered to be tampered; if all code blocks in the G-code file are not tampered, the file passes the authenticationVerifying;
if the G-code file passes the authentication, recovering the part I of each code block by the recovery watermark embedded in the corresponding mapping block; namely, it isMay be combined byThe lowest m bits of the bit sequence are obtained;
if the G-code file is not authenticated, the tampered command line is partially restored.
Further, the partially recovering the tampered command line if the G-code file is not authenticated comprises:
part I of based onThe embedded recovery watermark is recovered in its entirety,part II of (1) is based on the code blockAnd its adjacent blocksEstimating the geometrical information of:
wherein k is 1, 2.., n-1;andare respectively asAnda decimal representation of the X coordinate in the recovered portion I;
by passingFront and rear code blocks, i.e.Andthe geometrical information in (1) is estimated, the code blockThe X coordinate in (a) can be estimated by equation (2):
wherein k is 1, 2.., n;andare respectively asAndthe decimal representation of the X coordinate of the recovered portion I of (a);
Further, after the step 7, the method further comprises:
measuring the effect of the G-code file being restored according to the formula (3);
whereinIs an original G-code file and is,the recovered watermark-containing G-code file of the original G-code file, N is the total number of G0 and G1 command lines in the G-code file, xi、yiIs thatX, Y coordinates, x 'in the ith command line'iAnd y'iThen isWherein x and y areAnd (4) a set of coordinates of center X, Y, IQR (·) representing a quartile range of data.
Compared with the prior art, the invention has the following beneficial effects:
according to the published data, a method for authenticating the authenticity of the G-code file used for 3D printing is not found at present, the method can authenticate whether the G-code file is tampered or not, and the safety of using the G-code file in the 3D printing process can be improved. In addition, the method can locate and recover which contents in the G-code file are tampered, and the method for locating and recovering the G-code file tampering is not available in the prior art.
Drawings
FIG. 1 is a schematic view of 3D printing;
FIG. 2 is a schematic diagram of a G-code file format;
FIG. 3 is a flowchart of a G-code file authentication and recovery method based on self-embedded watermarks according to an embodiment of the present invention;
FIG. 4 is a 3D model corresponding to a G-code file in an embodiment of the present invention;
FIG. 5 is a graph of the average relative difference between an original G-code file and a watermarked G-code file or a restored watermarked G-code file in an embodiment of the present invention;
FIG. 6 is a 3D print generated using a recovered watermarked G-code file in an embodiment of the present invention;
FIG. 7 is a tamper detection error rate for G-code files with different levels of tampering according to an embodiment of the present invention;
FIG. 8 is a graph of the average relative difference between an original G-code file and a tampered G-code file or a recovered G-code file in an embodiment of the present invention.
Detailed Description
The invention is further illustrated by the following examples in conjunction with the accompanying drawings:
as shown in FIG. 3, the G-code file authentication and recovery method based on the self-embedded watermark comprises watermark embedding, and G-code authentication and recovery. In the watermark embedding process, the command lines in the G-code file are divided into code blocks. The code blocks are randomly scrambled to obtain a new sequence and mapping relation between the blocks. Each code block is divided into two parts, and an authentication watermark and a recovery watermark are generated using the X and Y coordinates in the first part of the code block. The authentication watermark is then embedded onto the least significant bits of the X and Y coordinates in the first part of the code block. At the same time, the recovery watermark is embedded within the X and Y coordinates in the second portion of the mapped code block.
When the 3D printer is subjected to a potentially attacked G-code file, it first determines whether the code blocks have been tampered with by verifying the authentication watermark in each code block. Whereas in the recovery phase, if not tampered with, the first part of each code block can be completely recovered from the recovery watermark in its mapped block. However, if a block of a code is tampered with and its mapped block is not, the first part of the block is still fully recoverable, and the second part is recovered from the geometry information of the neighboring blocks. When a certain code block and its mapping block are tampered with, the recovery of the block is completely based on the geometric information of its neighboring blocks.
A G-code file authentication and recovery method based on self-embedded watermarks specifically comprises the following steps:
(1) watermark embedding
For a given G-code file, the specific steps of the watermark embedding process are as follows:
step S101, divide the G0 and G1 command lines in the G-code file into code blocks and scramble with function P.
In particular, the use of code blocks as a minimal unit for tamper detection and recovery is based on the assumption that an attacker must tamper with multiple successive command lines in order to reach the goal of breaking the model. Since most of the geometric information during 3D printing is contained in the G0 and G1 command lines, we divide the G0 and G1 command lines into a plurality of code blocks, each of which contains n lines of code, denoted asWhere N is the total number of G0 and G1 command lines in the G-code file. Then is covered withScrambling the original code block sequence by using a function P with s as a random seed to obtain a new code block sequence,we will code the blockThe mapping block of (A) is denoted asIn addition, the last code block in the scrambling sequence is scrambledIs the first code block in the scrambling sequence
Step S102, selecting a watermark embedding domain: dividing each scrambled code block into two parts, wherein part I is a first command line, part II is a residual command line, X and Y coordinates in the part I are used for generating an authentication watermark and a recovery watermark, and X and Y coordinates in the part II are used for bearing the recovery watermark.
Specifically, each code block is divided into two parts: part I is the first command line, denotedPart II is the remaining n-1 command lines, denotedWhereinAt the same time, the user can select the desired position,the X and Y coordinates in (1) are used to generate the authentication watermark and the recovery watermark. The X and Y coordinates in part II of the code block are used to carry the recovery watermark.
Step S103, converting X and Y into binary representation.
Specifically, whereas the accuracy of the X and Y coordinates in the G-code file is substantially three decimal places, all the numbers of the X and Y coordinates are shifted three decimal places to the left, resulting in one decimal integer. Then, the decimal integer is converted into a binary integer with the length of p, and the binary integer is recorded asAndwherein i is 1, 2.
And step S104, respectively inputting the highest bit information of a plurality of X and Y coordinates in the part I of each code block into the FNV hash function to generate an authentication watermark, and embedding the authentication watermark into the code block.
Further, for the scrambled code blockThe part(s) of (1) is,n is the number of code lines contained in each code block; in which the binary representation of the X coordinate is denoted byWhileThe highest p-6 bit information is input into the FNV hash function and a 6-bit authentication watermark is generatedThen, after that,the lowest 6 bits are replaced byTo obtainThe above steps are equally applied to the Y coordinate.
Step S105, embedding a recovery watermark in the mapping block, wherein the recovery watermark of the code block is the bit information of the part I of the code block before embedding the authentication watermark.
Further, the code blockThe recovery watermark is bit information of a part I of the code block before embedding the authentication watermarkAndcode blockIs mapped to a blockX and Y coordinates in part IIIs the lowest ofBit replacement by code blockThe watermark is recovered. For example, when p is 20 and n is 5, thenBearThe 20 bits of the watermark are recovered. Scrambling the last code block in the sequenceIs embedded in the first code block of the sequence.
Step S106, after embedding the authentication watermark and recovering the watermark, the X and Y coordinates are converted from the binary representation to the decimal representation with the same precision as the original precision.
(2) Authentication and recovery of G-code
For a given G-code file, after the watermark embedding process, the G-code authentication and recovery process comprises the following specific steps:
step S107, when the 3D printer receives a G-code file, firstly checking whether the G-code file is tampered; if no tampering is detected, recovering distortion caused by the authentication watermark according to the recovery watermark; if the G-code file is tampered, partial recovery is performed using the recovery watermark and the geometric information of the adjacent code blocks.
Further, the step S107 includes:
dividing the command lines of G0 and G1 in the received G-code file into code blocks and scrambling by using a function P; dividing each code block after scrambling into two parts, wherein part I is a first command line, and part II is the rest command line; obtaining binary representation of X and Y coordinates of each code block; computing authentication watermarks for each code blockIf it is notAre respectively connected withIs the same, then the code block is consideredNot tampered, otherwise, the card is considered to be tampered; if all code blocks in the G-code file are not tampered, the file passes the authentication;
if the G-code file is authenticated, then portion I of each code block is passed through the recovery watermark embedded in its corresponding mapping blockRecovering; namely, it isMay be combined byThe lowest m bits of the bit sequence are obtained;
on the other hand, if the G-code file is not authenticated, the tampered command line can be partially restored; depending on the authentication result of the code block, two situations may occur:
1) code blockIs tampered with, maps blocks thereofHas not been tampered with. If this is the case, it is possible to do so,can be based onThe embedded recovery watermark is completely recovered.Part II of (1) is based on code blocksAnd its adjacent blocksIs estimated. Will be provided withAndthe decimal representation of the X coordinate in the recovered part I is noted asAndthen it is determined that,the X coordinate of part II is calculated according to the following formula:
wherein k is 1, 2.
2) Code blockAndare tampered with. In this case, the recovery cannot be completedPart I and part II of (1), but may be prepared byFront and rear code blocks, i.e.Andthe geometric information in (1) is estimated.Andmarking of X-position of fraction I after recoveryAndcode blockThe X coordinate of (a) can be estimated by:
where k is 1, 2.
For code blockThe estimation of the middle Y coordinate is similar to the above. This estimation method is based on the observation that both the X and Y coordinates in adjacent command lines have a strong linear dependence.
In order to check the effect of the proposed method, experiments were performed with respect to the invisibility of the watermark, the accuracy of tamper detection, and the G-code file recovery effect.
We first propose a measure of two G-code files (denoted asAnd) An index of the Difference, called Average Relative Difference (ARD), is calculated as follows:
where N is the total number of G0 and G1 command lines in the G-code file, xi、yiIs a G-code fileX, Y coordinate, x, in the ith command linei' and yiIs thenCorresponding content in the content list; x and y areA set of coordinates of center X, Y; IQR (-) represents the quartering distance of the data.
This index reflects the average euclidean distance of the geometric information in the two G-code files while taking into account the overall size of the object. When in useAndthe index measures the distortion brought by the watermark embedded in the G-code file when the original file and the watermark embedded file are respectively represented. When in useAndthe index measures the distortion of the G-code file caused by tampering when representing the original file and the tampered file respectively. When in useAndthis index measures the effect of the G-code file being restored when representing the original file and the restored file, respectively. It should be noted that this criterion requires that the number of command lines in the two G-code files must be consistent.
In the experiment, four G-code files for 3D printing were used as the original G-code files. The shape of the four 3D prints is shown in fig. 4. The G-code file was generated from the Cura 4.10.0 version with the print parameters set as follows, a fill density of 20%, a layer height of 0.16 mm, and a print speed of 60 mm/sec.
a. Invisibility analysis experiment
In analyzing the invisibility of the watermark, we apply the proposed self-embedding watermarking method to the above four G-code files. While the embedding parameters are set to different values to study their effect on watermark embedding distortion.
Analyzing watermark distortion theoretically, if the G-code file is authenticated, the distortion caused by embedding the authentication watermark is reversible, since part I of each code block can be completely recovered based on the recovery watermark embedded in its mapped block. Then only the recovered watermark embedded in each code block portion II will cause distortion. In practice, these embedded changes are limited to the lowest m bits of the binary representation of the X and Y coordinates,where n is the number of command lines in each code block and p is the length of the number of bits in binary representation of the X and Y coordinates. We set the embedding parameter to (p, n) ∈ { (20,21), (20,11), (21,8), (20,6), (20,5), (21,4) }, then m ∈ {1,2,3,4,5,7 }. The parameters are used in the process of embedding the watermarks in the four G-code files.
We will note the original G-code file asG-code file with embedded watermark is recordedWatermark-containing G-code files restored based on the restored watermarks are denotedComputing G-code filesAndthe average relative difference between them is recorded as ARDw(representing the average relative difference between the original G-code file and the restored watermarked G-code file),andthe average relative difference between them is denoted as ARDr(represents the average relative difference between the original G-code file and the restored watermarked G-code file). ARD for four test G-code fileswAnd ARDrAs shown in fig. 5. When m is less than or equal to 5, the watermark embedding distortion is very limited. At the same time, the ARD is in each caserAre all less than ARDwThis verifies that the restoration of code block portion I can further reduce distortion.
Further, the corresponding part was printed using the recovered watermark G-code file (m ═ 4), as shown in fig. 6. The 3D printer model is JGAURORA A8L, and the precision can reach 0.05 mm. It can be seen from fig. 6 that the effect of the embedding distortion of the G-code file on the 3D print is very limited.
b. Tamper detection experiment
To test the accuracy of tamper detection, we simulated a tamper operation by moving the position of the X and Y coordinates in multiple command lines. In this part of the experiment, the corresponding watermarked G-code file of fig. 4 (a) was used. The parameter falsification ratio T is a ratio of falsified command lines to all command lines, and is set to {0.01, 0.02, 0.03, 0.04, 0.05 }. The tampered command line is a set of randomly initiated adjacent command lines. And the offset magnitudes of the X and Y coordinates are set to 10% xiqr (X) and 10% xiqr (Y), where X and Y are the sets of X and Y coordinates in the watermarked G-code file, respectively. The watermark embedding parameter is set to (p, n) ∈ { (20,11), (21,8), (20,6), (20,5), (21,4) }. The detection error rate is the average value of the false alarm rate and the omission factor.
Fig. 7 shows the results of tamper detection for G-code files at different levels of tampering. As can be seen from FIG. 7, errors are detected in each caseThe error rates are all lower than 6 x 10-4. And as n increases, the error rate tends to decrease. This is because the tampered portion is detected in the smallest unit of the code block, and a smaller n value represents a smaller code block size, which contributes to improvement of detection accuracy. Fig. 7 shows that when the number is less than or equal to 6, the proposed method can achieve a relatively stable tamper detection effect.
c.G-code File recovery experiment
To test the recovery capability of the proposed method, we utilized the corresponding G-code file of fig. 4 as the original file. The watermark embedding parameter is set to (p, n) ═ 20, 6. The tampering process is the same as the process in the tampering detection experiment, and the tampering rate is T E {0.01, 0.02, 0.03, 0.04, 0.05 }. The average relative difference between the original file and the tampered G-code file is denoted as ARDt. The average relative difference between the original file and the tampered and recovered G-code file is denoted as ARDr。
The recovery effect of the tampered G-code file can be achieved through the ARD in FIG. 8t(representing average relative difference of original G-code file and tampered G-code file) and ARDr(representing the average relative difference between the original G-code file and the restored G-code file). As shown in FIG. 8, the average relative difference between the tampered file and the original file can be significantly reduced by the proposed method, which indicates that the G-code file is more effectively restored.
In conclusion, the method and the device can authenticate whether the G-code file is tampered or not, and can improve the safety of using the G-code file in the 3D printing process. In addition, the method can locate which contents in the G-code file are tampered and recover the contents.
The above shows only the preferred embodiments of the present invention, and it should be noted that it is obvious to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and these modifications and improvements should also be considered as the protection scope of the present invention.
Claims (7)
1. A G-code file authentication and recovery method based on self-embedded watermark is characterized by comprising the following steps:
step 1, dividing G0 and G1 command lines in a G-code file into code blocks and scrambling by using a function P;
step 2, selecting a watermark embedding domain: dividing each scrambled code block into two parts, wherein part I is a first command line, part II is a residual command line, X and Y coordinates in the part I are used for generating an authentication watermark and a recovery watermark, and X and Y coordinates in the part II are used for bearing the recovery watermark;
step 3, converting X and Y into binary representation;
step 4, respectively inputting the highest bit information of a plurality of X and Y coordinates in the part I of each code block into an FNV hash function to generate an authentication watermark, and embedding the authentication watermark into the code block;
step 5, embedding a recovery watermark in the mapping block, wherein the recovery watermark of the code block is bit information of a part I of the code block before embedding the authentication watermark;
step 6, after embedding the authentication watermark and recovering the watermark, converting the X and Y coordinates from the binary representation into a decimal representation with the same accuracy as the original accuracy;
step 7, when the 3D printer receives a G-code file, firstly checking whether the G-code file is tampered; if no tampering is detected, recovering distortion caused by the authentication watermark according to the recovery watermark; if the G-code file is tampered, partial recovery is performed using the recovery watermark and the geometric information of the adjacent code blocks.
2. The self-embedded watermark-based G-code file authentication and recovery method according to claim 1, wherein the step 3 comprises:
translating all the numbers of the X and Y coordinates to the left by three digits to obtain a decimal integer; then, the decimal integer is converted into a binary integer with the length of p, and the binary integer is recorded asAndwhere i 1, 2.., N, where N is the total number of G0 and G1 command lines in the G-code file.
3. The self-embedded watermark-based G-code file authentication and recovery method according to claim 2, wherein the step 4 comprises:
for the scrambled code blockThe part(s) of (1) is,n is the number of code lines contained in each code block; in which the binary representation of the X coordinate is denoted byWhileThe highest p-6 bit information is input into the FNV hash function and a 6-bit authentication watermark is generatedThen, after that,the lowest 6 bits are replaced byTo obtainThe above steps are equally applied to the Y coordinate.
4. The self-embedded watermark-based G-code file authentication and recovery method according to claim 3, wherein the step 5 comprises:
code blockThe recovery watermark is bit information of a part I of the code block before embedding the authentication watermarkAndcode blockIs mapped to a blockX and Y coordinates in part IIIs the lowest ofBit replacement by code blockRecovering the watermark; the recovered watermark of the last code block in the scrambled sequence is embedded in the first code block of the sequence.
5. The self-embedded watermark-based G-code file authentication and recovery method according to claim 4, wherein the step 7 comprises:
dividing the command lines of G0 and G1 in the received G-code file into code blocks and scrambling by using a function P; dividing each code block after scrambling into two parts, wherein part I is a first command line, and part II is the rest command line; obtaining binary representation of X and Y coordinates of each code block; computing authentication watermarks for each code blockIf it is notAre respectively connected withIs the same, then the code block is consideredNot tampered, otherwise, the card is considered to be tampered; if all code blocks in the G-code file are not tampered, the file passes the authentication;
if the G-code file passes the authentication, recovering the part I of each code block by the recovery watermark embedded in the corresponding mapping block; namely, it isMay be combined byThe lowest m bits of the bit sequence are obtained;
if the G-code file is not authenticated, the tampered command line is partially restored.
6. The self-embedded watermark-based G-code file authentication and recovery method of claim 5, wherein if the G-code file is not authenticated, partially recovering the tampered command line comprises:
part I of based onThe embedded recovery watermark is recovered in its entirety,part II of (1) is based on the code blockAnd its adjacent blocksEstimating the geometrical information of:
wherein k is 1, 2.., n-1;andare respectively asAnda decimal representation of the X coordinate in the recovered portion I;
by passingFront and rear code blocks, i.e.Andthe geometrical information in (1) is estimated, the code blockThe X coordinate in (a) can be estimated by equation (2):
wherein k is 1, 2.., n;andare respectively asAndthe decimal representation of the X coordinate of the recovered portion I of (a);
7. The self-embedded watermark-based G-code file authentication and recovery method according to claim 1, further comprising, after the step 7:
measuring the effect of the G-code file being restored according to the formula (3);
whereinIs an original G-code file and is,for the recovered watermarked G-code file, N is the total number of G0 and G1 command lines in the G-code file, xi、yiIs thatX, Y coordinates, x 'in the ith command line'iAnd y'iThen isWherein x and y areAnd (4) a set of coordinates of center X, Y, IQR (·) representing a quartile range of data.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111109077.9A CN113934989B (en) | 2021-09-22 | 2021-09-22 | G-code file authentication and recovery method based on self-embedded watermark |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111109077.9A CN113934989B (en) | 2021-09-22 | 2021-09-22 | G-code file authentication and recovery method based on self-embedded watermark |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113934989A true CN113934989A (en) | 2022-01-14 |
CN113934989B CN113934989B (en) | 2024-04-26 |
Family
ID=79276377
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111109077.9A Active CN113934989B (en) | 2021-09-22 | 2021-09-22 | G-code file authentication and recovery method based on self-embedded watermark |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113934989B (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101409813A (en) * | 2007-10-08 | 2009-04-15 | 陈诚 | Image encoding method for preventing and identifying image tamper |
CN101527850A (en) * | 2009-04-10 | 2009-09-09 | 北京航空航天大学 | Video self-recovery watermark method based on motion estimation |
US20120275641A1 (en) * | 2011-04-28 | 2012-11-01 | King Abdul Aziz City For Science And Technology | Method and apparatus for embedding a watermark image in a host image |
CN104778651A (en) * | 2015-03-31 | 2015-07-15 | 北京交通大学 | Digital image authentication method based on super-pixels |
CN106599727A (en) * | 2016-12-02 | 2017-04-26 | 江苏师范大学 | Vector map integrity authentication method |
CN107742272A (en) * | 2017-10-17 | 2018-02-27 | 大连理工大学 | A kind of semi-fragile watermarks method for positioning and recovering based on distorted image |
CN110148079A (en) * | 2019-05-27 | 2019-08-20 | 福建师范大学福清分校 | A kind of digital image tampering detection positioning and self-healing method |
-
2021
- 2021-09-22 CN CN202111109077.9A patent/CN113934989B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101409813A (en) * | 2007-10-08 | 2009-04-15 | 陈诚 | Image encoding method for preventing and identifying image tamper |
CN101527850A (en) * | 2009-04-10 | 2009-09-09 | 北京航空航天大学 | Video self-recovery watermark method based on motion estimation |
US20120275641A1 (en) * | 2011-04-28 | 2012-11-01 | King Abdul Aziz City For Science And Technology | Method and apparatus for embedding a watermark image in a host image |
CN104778651A (en) * | 2015-03-31 | 2015-07-15 | 北京交通大学 | Digital image authentication method based on super-pixels |
CN106599727A (en) * | 2016-12-02 | 2017-04-26 | 江苏师范大学 | Vector map integrity authentication method |
CN107742272A (en) * | 2017-10-17 | 2018-02-27 | 大连理工大学 | A kind of semi-fragile watermarks method for positioning and recovering based on distorted image |
CN110148079A (en) * | 2019-05-27 | 2019-08-20 | 福建师范大学福清分校 | A kind of digital image tampering detection positioning and self-healing method |
Non-Patent Citations (6)
Title |
---|
ARNAUD DELMOTTE 等: "Blind Watermarking for 3-D Printed Objects by Locally Modifying Layer Thickness", IEEE TRANSACTIONS ON MULTIMEDIA, vol. 22, no. 11, 30 November 2020 (2020-11-30), pages 2780 - 2791, XP011816227, DOI: 10.1109/TMM.2019.2962306 * |
ZHENYU LI 等, 2021 IEEE INTERNATIONAL WORKSHOP ON INFORMATION FORENSICS AND SECURITY(WIFS), 24 December 2021 (2021-12-24), pages 1 - 6 * |
孟晓: "分数阶傅里叶变换在数字水印中的应用", 中国优秀硕士学位论文全文数据库 信息科技辑, no. 04, 15 April 2012 (2012-04-15), pages 138 - 73 * |
李振宏 等: "一种基于SIFT变换的抗几何攻击第二代数字水印", 微电子学与计算机, vol. 25, no. 04, 5 April 2008 (2008-04-05), pages 1 - 4 * |
赵圆圆: "基于置乱加密和数字水印的数字版权管理系统客户端设计", 中国优秀硕士学位论文全文数据库 信息科技辑, no. 12, 15 December 2010 (2010-12-15), pages 138 - 94 * |
魏飒 等: "一种基于DWT域的多目的彩色音频水印算法", 信息技术, no. 07, 25 July 2015 (2015-07-25), pages 12 - 16 * |
Also Published As
Publication number | Publication date |
---|---|
CN113934989B (en) | 2024-04-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7171021B2 (en) | Data processing apparatus and method, and storage medium therefor | |
US6862362B2 (en) | Parity-grid steganographic method and apparatus | |
KR100878579B1 (en) | Watermarking Method, Watermark Validation Method, Watermarking Device and Watermark Validation Device | |
CN107742272B (en) | Semi-fragile watermarking method based on image tampering positioning and recovery | |
WO2018212811A1 (en) | Hiding information and images via deep learning | |
KR101744744B1 (en) | System for tracking illegal distributeur and preventing distribution of illegal content and method thereof | |
EP3236389A1 (en) | Apparatus and method for 3d printing | |
CN102903075B (en) | Robust watermarking method based on image feature point global correction | |
CN102932650B (en) | Video data integrity protection and verification method, equipment and system | |
Hou et al. | Copyright protections of digital content in the age of 3d printer: Emerging issues and survey | |
Rajput et al. | Image tamper detection and self-recovery using multiple median watermarking | |
CN103440617A (en) | Image processing method for improving safety of medical image | |
CN109919824B (en) | Color image zero watermarking method based on fast quaternion generalized extremely complex exponential transformation | |
JP4319157B2 (en) | Image processing method, falsification detection method, image processing apparatus, falsification detection apparatus | |
Gao et al. | ThermoTag: A hidden ID of 3D printers for fingerprinting and watermarking | |
Raj et al. | Blockwise fragile watermarking schemes for tamper localization in digital images | |
JP3988599B2 (en) | Image processing method, falsification detection method, image processing apparatus, falsification detection apparatus, image processing program, falsification detection program, and image forming medium | |
CN113934989B (en) | G-code file authentication and recovery method based on self-embedded watermark | |
CN103971324A (en) | Asymmetric watermarking method for protecting vector map data copyright | |
Li et al. | Self-embedding watermarking method for G-code used in 3D printing | |
CN111242825B (en) | Water depth feature-based ENC electronic nautical chart zero-watermarking method | |
CN116805069A (en) | Track data zero watermark generation method, track data zero watermark detection device and storage medium | |
Huang et al. | Recoverable Active Protection Framework for Neural Network Models | |
Chen et al. | Adaptive authentication schemes for 3D mesh models | |
CN116320200B (en) | Multi-point fusion anti-cracking encryption method applied to two-dimensional code |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |