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 PDF

Info

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
Application number
CN202111109077.9A
Other languages
Chinese (zh)
Other versions
CN113934989B (en
Inventor
李震宇
巩道福
谭磊
罗向阳
刘粉林
杨春芳
杜少勇
杨忠信
张昕
张明亮
范文同
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Information Engineering University of PLA Strategic Support Force
Original Assignee
Information Engineering University of PLA Strategic Support Force
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Information Engineering University of PLA Strategic Support Force filed Critical Information Engineering University of PLA Strategic Support Force
Priority to CN202111109077.9A priority Critical patent/CN113934989B/en
Publication of CN113934989A publication Critical patent/CN113934989A/en
Application granted granted Critical
Publication of CN113934989B publication Critical patent/CN113934989B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/16Program or content traceability, e.g. by watermarking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting 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

G-code file authentication and recovery method based on self-embedded watermark
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:
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.
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 as
Figure BDA0003273441030000031
And
Figure BDA0003273441030000032
where 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 block
Figure BDA0003273441030000038
The part(s) of (1) is,
Figure BDA0003273441030000033
n is the number of code lines contained in each code block; in which the binary representation of the X coordinate is denoted by
Figure BDA0003273441030000034
While
Figure BDA0003273441030000035
The highest p-6 bit information is input into the FNV hash function and a 6-bit authentication watermark is generated
Figure BDA0003273441030000036
Then, after that,
Figure BDA0003273441030000037
the lowest 6 bits are replaced by
Figure BDA0003273441030000041
To obtain
Figure BDA0003273441030000042
The above steps are equally applied to the Y coordinate.
Further, the step 5 comprises:
code block
Figure BDA0003273441030000043
The recovery watermark is bit information of a part I of the code block before embedding the authentication watermark
Figure BDA0003273441030000044
And
Figure BDA0003273441030000045
code block
Figure BDA0003273441030000046
Is mapped to a block
Figure BDA0003273441030000047
X and Y coordinates in part II
Figure BDA0003273441030000048
Is the lowest of
Figure BDA0003273441030000049
Bit replacement by code block
Figure BDA00032734410300000410
Recovering 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 block
Figure BDA00032734410300000411
If it is not
Figure BDA00032734410300000412
Are respectively connected with
Figure BDA00032734410300000413
Is the same, then the code block is considered
Figure BDA00032734410300000414
Not 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 is
Figure BDA00032734410300000415
May be combined by
Figure BDA00032734410300000416
The 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:
1) code block
Figure BDA00032734410300000417
Is tampered with, maps blocks thereof
Figure BDA00032734410300000418
Not tampered with;
Figure BDA00032734410300000419
part I of based on
Figure BDA00032734410300000420
The embedded recovery watermark is recovered in its entirety,
Figure BDA00032734410300000421
part II of (1) is based on the code block
Figure BDA00032734410300000422
And its adjacent blocks
Figure BDA00032734410300000423
Estimating the geometrical information of:
Figure BDA00032734410300000424
wherein k is 1, 2.., n-1;
Figure BDA00032734410300000425
and
Figure BDA00032734410300000426
are respectively as
Figure BDA00032734410300000427
And
Figure BDA00032734410300000428
a decimal representation of the X coordinate in the recovered portion I;
2) code block
Figure BDA0003273441030000051
And
Figure BDA0003273441030000052
are all tampered with;
by passing
Figure BDA0003273441030000053
Front and rear code blocks, i.e.
Figure BDA0003273441030000054
And
Figure BDA0003273441030000055
the geometrical information in (1) is estimated, the code block
Figure BDA0003273441030000056
The X coordinate in (a) can be estimated by equation (2):
Figure BDA0003273441030000057
wherein k is 1, 2.., n;
Figure BDA0003273441030000058
and
Figure BDA0003273441030000059
are respectively as
Figure BDA00032734410300000510
And
Figure BDA00032734410300000511
the decimal representation of the X coordinate of the recovered portion I of (a);
code block obtained by the same method
Figure BDA00032734410300000512
And (4) estimating a middle Y coordinate.
Further, after the step 7, the method further comprises:
measuring the effect of the G-code file being restored according to the formula (3);
Figure BDA00032734410300000513
wherein
Figure BDA00032734410300000514
Is an original G-code file and is,
Figure BDA00032734410300000515
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 that
Figure BDA00032734410300000516
X, Y coordinates, x 'in the ith command line'iAnd y'iThen is
Figure BDA00032734410300000517
Wherein x and y are
Figure BDA00032734410300000518
And (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 as
Figure BDA0003273441030000071
Where 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,
Figure BDA0003273441030000072
we will code the block
Figure BDA0003273441030000073
The mapping block of (A) is denoted as
Figure BDA0003273441030000074
In addition, the last code block in the scrambling sequence is scrambled
Figure BDA0003273441030000075
Is the first code block in the scrambling sequence
Figure BDA0003273441030000076
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, denoted
Figure BDA0003273441030000077
Part II is the remaining n-1 command lines, denoted
Figure BDA0003273441030000078
Wherein
Figure BDA0003273441030000079
At the same time, the user can select the desired position,
Figure BDA00032734410300000710
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 as
Figure BDA00032734410300000711
And
Figure BDA00032734410300000712
wherein 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 block
Figure BDA00032734410300000713
The part(s) of (1) is,
Figure BDA00032734410300000714
n is the number of code lines contained in each code block; in which the binary representation of the X coordinate is denoted by
Figure BDA00032734410300000715
While
Figure BDA00032734410300000716
The highest p-6 bit information is input into the FNV hash function and a 6-bit authentication watermark is generated
Figure BDA00032734410300000717
Then, after that,
Figure BDA00032734410300000718
the lowest 6 bits are replaced by
Figure BDA00032734410300000719
To obtain
Figure BDA00032734410300000720
The 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 block
Figure BDA0003273441030000081
The recovery watermark is bit information of a part I of the code block before embedding the authentication watermark
Figure BDA0003273441030000082
And
Figure BDA0003273441030000083
code block
Figure BDA0003273441030000084
Is mapped to a block
Figure BDA0003273441030000085
X and Y coordinates in part II
Figure BDA0003273441030000086
Is the lowest of
Figure BDA0003273441030000087
Bit replacement by code block
Figure BDA0003273441030000088
The watermark is recovered. For example, when p is 20 and n is 5, then
Figure BDA0003273441030000089
Bear
Figure BDA00032734410300000810
The 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 block
Figure BDA00032734410300000811
If it is not
Figure BDA00032734410300000812
Are respectively connected with
Figure BDA00032734410300000813
Is the same, then the code block is considered
Figure BDA00032734410300000814
Not 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 is
Figure BDA00032734410300000815
May be combined by
Figure BDA00032734410300000816
The 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 block
Figure BDA0003273441030000091
Is tampered with, maps blocks thereof
Figure BDA0003273441030000092
Has not been tampered with. If this is the case, it is possible to do so,
Figure BDA0003273441030000093
can be based on
Figure BDA0003273441030000094
The embedded recovery watermark is completely recovered.
Figure BDA0003273441030000095
Part II of (1) is based on code blocks
Figure BDA0003273441030000096
And its adjacent blocks
Figure BDA0003273441030000097
Is estimated. Will be provided with
Figure BDA0003273441030000098
And
Figure BDA0003273441030000099
the decimal representation of the X coordinate in the recovered part I is noted as
Figure BDA00032734410300000910
And
Figure BDA00032734410300000911
then it is determined that,
Figure BDA00032734410300000912
the X coordinate of part II is calculated according to the following formula:
Figure BDA00032734410300000913
wherein k is 1, 2.
2) Code block
Figure BDA00032734410300000914
And
Figure BDA00032734410300000915
are tampered with. In this case, the recovery cannot be completed
Figure BDA00032734410300000916
Part I and part II of (1), but may be prepared by
Figure BDA00032734410300000917
Front and rear code blocks, i.e.
Figure BDA00032734410300000918
And
Figure BDA00032734410300000919
the geometric information in (1) is estimated.
Figure BDA00032734410300000920
And
Figure BDA00032734410300000921
marking of X-position of fraction I after recovery
Figure BDA00032734410300000922
And
Figure BDA00032734410300000923
code block
Figure BDA00032734410300000924
The X coordinate of (a) can be estimated by:
Figure BDA00032734410300000925
where k is 1, 2.
For code block
Figure BDA00032734410300000926
The 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 as
Figure BDA00032734410300000927
And
Figure BDA00032734410300000928
) An index of the Difference, called Average Relative Difference (ARD), is calculated as follows:
Figure BDA00032734410300000929
where N is the total number of G0 and G1 command lines in the G-code file, xi、yiIs a G-code file
Figure BDA00032734410300000930
X, Y coordinate, x, in the ith command linei' and yiIs then
Figure BDA0003273441030000101
Corresponding content in the content list; x and y are
Figure BDA0003273441030000102
A 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 use
Figure BDA0003273441030000103
And
Figure BDA0003273441030000104
the 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 use
Figure BDA0003273441030000105
And
Figure BDA0003273441030000106
the index measures the distortion of the G-code file caused by tampering when representing the original file and the tampered file respectively. When in use
Figure BDA0003273441030000107
And
Figure BDA0003273441030000108
this 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,
Figure BDA0003273441030000109
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 as
Figure BDA00032734410300001010
G-code file with embedded watermark is recorded
Figure BDA00032734410300001011
Watermark-containing G-code files restored based on the restored watermarks are denoted
Figure BDA00032734410300001012
Computing G-code files
Figure BDA00032734410300001013
And
Figure BDA00032734410300001014
the 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),
Figure BDA0003273441030000111
and
Figure BDA0003273441030000112
the 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 as
Figure FDA0003273441020000011
And
Figure FDA0003273441020000012
where 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 block
Figure FDA0003273441020000013
The part(s) of (1) is,
Figure FDA0003273441020000014
n is the number of code lines contained in each code block; in which the binary representation of the X coordinate is denoted by
Figure FDA0003273441020000015
While
Figure FDA0003273441020000016
The highest p-6 bit information is input into the FNV hash function and a 6-bit authentication watermark is generated
Figure FDA0003273441020000017
Then, after that,
Figure FDA0003273441020000018
the lowest 6 bits are replaced by
Figure FDA0003273441020000019
To obtain
Figure FDA00032734410200000110
The 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 block
Figure FDA0003273441020000021
The recovery watermark is bit information of a part I of the code block before embedding the authentication watermark
Figure FDA0003273441020000022
And
Figure FDA0003273441020000023
code block
Figure FDA0003273441020000024
Is mapped to a block
Figure FDA0003273441020000025
X and Y coordinates in part II
Figure FDA0003273441020000026
Is the lowest of
Figure FDA0003273441020000027
Bit replacement by code block
Figure FDA0003273441020000028
Recovering 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 block
Figure FDA0003273441020000029
If it is not
Figure FDA00032734410200000210
Are respectively connected with
Figure FDA00032734410200000211
Is the same, then the code block is considered
Figure FDA00032734410200000212
Not 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 is
Figure FDA00032734410200000213
May be combined by
Figure FDA00032734410200000214
The 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:
1) code block
Figure FDA00032734410200000215
Is tampered with, maps blocks thereof
Figure FDA00032734410200000216
Not tampered with;
Figure FDA00032734410200000217
part I of based on
Figure FDA00032734410200000218
The embedded recovery watermark is recovered in its entirety,
Figure FDA00032734410200000219
part II of (1) is based on the code block
Figure FDA00032734410200000220
And its adjacent blocks
Figure FDA00032734410200000221
Estimating the geometrical information of:
Figure FDA0003273441020000031
wherein k is 1, 2.., n-1;
Figure FDA0003273441020000032
and
Figure FDA0003273441020000033
are respectively as
Figure FDA0003273441020000034
And
Figure FDA0003273441020000035
a decimal representation of the X coordinate in the recovered portion I;
2) code block
Figure FDA0003273441020000036
And
Figure FDA0003273441020000037
are all tampered with;
by passing
Figure FDA0003273441020000038
Front and rear code blocks, i.e.
Figure FDA0003273441020000039
And
Figure FDA00032734410200000310
the geometrical information in (1) is estimated, the code block
Figure FDA00032734410200000311
The X coordinate in (a) can be estimated by equation (2):
Figure FDA00032734410200000312
wherein k is 1, 2.., n;
Figure FDA00032734410200000313
and
Figure FDA00032734410200000314
are respectively as
Figure FDA00032734410200000315
And
Figure FDA00032734410200000316
the decimal representation of the X coordinate of the recovered portion I of (a);
code block obtained by the same method
Figure FDA00032734410200000317
And (4) estimating a middle Y coordinate.
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);
Figure FDA00032734410200000318
wherein
Figure FDA00032734410200000319
Is an original G-code file and is,
Figure FDA00032734410200000320
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 that
Figure FDA00032734410200000321
X, Y coordinates, x 'in the ith command line'iAnd y'iThen is
Figure FDA00032734410200000322
Wherein x and y are
Figure FDA00032734410200000323
And (4) a set of coordinates of center X, Y, IQR (·) representing a quartile range of data.
CN202111109077.9A 2021-09-22 2021-09-22 G-code file authentication and recovery method based on self-embedded watermark Active CN113934989B (en)

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)

* Cited by examiner, † Cited by third party
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

Patent Citations (7)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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