theapk-ghostprint 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- theapk_ghostprint-0.1.1/LICENSE +84 -0
- theapk_ghostprint-0.1.1/PKG-INFO +235 -0
- theapk_ghostprint-0.1.1/README.md +136 -0
- theapk_ghostprint-0.1.1/pyproject.toml +23 -0
- theapk_ghostprint-0.1.1/setup.cfg +4 -0
- theapk_ghostprint-0.1.1/src/ghostprint/__init__.py +34 -0
- theapk_ghostprint-0.1.1/src/ghostprint/cli.py +117 -0
- theapk_ghostprint-0.1.1/src/ghostprint/core.py +461 -0
- theapk_ghostprint-0.1.1/src/theapk_ghostprint.egg-info/PKG-INFO +235 -0
- theapk_ghostprint-0.1.1/src/theapk_ghostprint.egg-info/SOURCES.txt +22 -0
- theapk_ghostprint-0.1.1/src/theapk_ghostprint.egg-info/dependency_links.txt +1 -0
- theapk_ghostprint-0.1.1/src/theapk_ghostprint.egg-info/entry_points.txt +2 -0
- theapk_ghostprint-0.1.1/src/theapk_ghostprint.egg-info/requires.txt +6 -0
- theapk_ghostprint-0.1.1/src/theapk_ghostprint.egg-info/top_level.txt +1 -0
- theapk_ghostprint-0.1.1/tests/test_browser_e2e.py +433 -0
- theapk_ghostprint-0.1.1/tests/test_checkout_route.py +273 -0
- theapk_ghostprint-0.1.1/tests/test_cli.py +161 -0
- theapk_ghostprint-0.1.1/tests/test_core_regression.py +228 -0
- theapk_ghostprint-0.1.1/tests/test_landing_serve.py +478 -0
- theapk_ghostprint-0.1.1/tests/test_limiter.py +69 -0
- theapk_ghostprint-0.1.1/tests/test_multipart.py +38 -0
- theapk_ghostprint-0.1.1/tests/test_rlimit.py +61 -0
- theapk_ghostprint-0.1.1/tests/test_round_trip.py +157 -0
- theapk_ghostprint-0.1.1/tests/test_tag_cli.py +97 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
PolyForm Noncommercial License 1.0.0
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 theapk llc
|
|
4
|
+
|
|
5
|
+
This source code is licensed under the PolyForm Noncommercial License
|
|
6
|
+
1.0.0, a copy of which is reproduced below.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# PolyForm Noncommercial License 1.0.0
|
|
11
|
+
|
|
12
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
13
|
+
|
|
14
|
+
## Terms
|
|
15
|
+
|
|
16
|
+
### 1. Purpose
|
|
17
|
+
|
|
18
|
+
This license gives you permission to use this software for any
|
|
19
|
+
noncommercial purpose. Commercial use requires a separate license
|
|
20
|
+
from the copyright holder.
|
|
21
|
+
|
|
22
|
+
### 2. Copyright
|
|
23
|
+
|
|
24
|
+
The copyright holder retains all copyright and related rights to
|
|
25
|
+
the software.
|
|
26
|
+
|
|
27
|
+
### 3. Grant of Rights
|
|
28
|
+
|
|
29
|
+
Subject to the terms and conditions of this license, the copyright
|
|
30
|
+
holder grants you a worldwide, royalty-free, non-exclusive,
|
|
31
|
+
non-transferable, non-sublicensable license to:
|
|
32
|
+
|
|
33
|
+
1. Use, copy, modify, merge, and distribute copies of the software,
|
|
34
|
+
for noncommercial purposes only.
|
|
35
|
+
|
|
36
|
+
2. Install and operate the software for your own personal,
|
|
37
|
+
educational, or research use.
|
|
38
|
+
|
|
39
|
+
3. Contribute modifications back to the project under the same
|
|
40
|
+
license.
|
|
41
|
+
|
|
42
|
+
### 4. Noncommercial Use
|
|
43
|
+
|
|
44
|
+
"Noncommercial use" means use that is not primarily intended for
|
|
45
|
+
or directed toward commercial advantage or monetary compensation.
|
|
46
|
+
Examples of noncommercial use include:
|
|
47
|
+
|
|
48
|
+
- Personal projects and hobbies
|
|
49
|
+
- Educational use in schools, universities, and courses
|
|
50
|
+
- Academic research
|
|
51
|
+
- Testing and evaluation
|
|
52
|
+
- Contributing to the open-source project itself
|
|
53
|
+
|
|
54
|
+
### 5. Commercial Use
|
|
55
|
+
|
|
56
|
+
"Commercial use" means any use that is primarily intended for or
|
|
57
|
+
directed toward commercial advantage or monetary compensation.
|
|
58
|
+
Examples of commercial use include:
|
|
59
|
+
|
|
60
|
+
- Selling the software or derivatives thereof
|
|
61
|
+
- Offering the software as a paid or ad-supported service
|
|
62
|
+
- Using the software in a commercial print farm or production
|
|
63
|
+
environment
|
|
64
|
+
- Embedding the software in a commercial product
|
|
65
|
+
- Using the software internally by a business to generate revenue
|
|
66
|
+
|
|
67
|
+
For commercial use, contact theapk llc to obtain a commercial
|
|
68
|
+
license: https://theapk.com or support@theapk.com
|
|
69
|
+
|
|
70
|
+
### 6. Conditions
|
|
71
|
+
|
|
72
|
+
You must include a copy of this license with every copy of the
|
|
73
|
+
software you distribute. You must include the copyright notice
|
|
74
|
+
above in all copies.
|
|
75
|
+
|
|
76
|
+
### 7. No Warranty
|
|
77
|
+
|
|
78
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
79
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
80
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
81
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
|
|
82
|
+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
83
|
+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
84
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: theapk-ghostprint
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Two-layer invisible watermark for 3D-printed parts (forensics, not DRM)
|
|
5
|
+
Author: theapk llc
|
|
6
|
+
License: PolyForm Noncommercial License 1.0.0
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 theapk llc
|
|
9
|
+
|
|
10
|
+
This source code is licensed under the PolyForm Noncommercial License
|
|
11
|
+
1.0.0, a copy of which is reproduced below.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# PolyForm Noncommercial License 1.0.0
|
|
16
|
+
|
|
17
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
18
|
+
|
|
19
|
+
## Terms
|
|
20
|
+
|
|
21
|
+
### 1. Purpose
|
|
22
|
+
|
|
23
|
+
This license gives you permission to use this software for any
|
|
24
|
+
noncommercial purpose. Commercial use requires a separate license
|
|
25
|
+
from the copyright holder.
|
|
26
|
+
|
|
27
|
+
### 2. Copyright
|
|
28
|
+
|
|
29
|
+
The copyright holder retains all copyright and related rights to
|
|
30
|
+
the software.
|
|
31
|
+
|
|
32
|
+
### 3. Grant of Rights
|
|
33
|
+
|
|
34
|
+
Subject to the terms and conditions of this license, the copyright
|
|
35
|
+
holder grants you a worldwide, royalty-free, non-exclusive,
|
|
36
|
+
non-transferable, non-sublicensable license to:
|
|
37
|
+
|
|
38
|
+
1. Use, copy, modify, merge, and distribute copies of the software,
|
|
39
|
+
for noncommercial purposes only.
|
|
40
|
+
|
|
41
|
+
2. Install and operate the software for your own personal,
|
|
42
|
+
educational, or research use.
|
|
43
|
+
|
|
44
|
+
3. Contribute modifications back to the project under the same
|
|
45
|
+
license.
|
|
46
|
+
|
|
47
|
+
### 4. Noncommercial Use
|
|
48
|
+
|
|
49
|
+
"Noncommercial use" means use that is not primarily intended for
|
|
50
|
+
or directed toward commercial advantage or monetary compensation.
|
|
51
|
+
Examples of noncommercial use include:
|
|
52
|
+
|
|
53
|
+
- Personal projects and hobbies
|
|
54
|
+
- Educational use in schools, universities, and courses
|
|
55
|
+
- Academic research
|
|
56
|
+
- Testing and evaluation
|
|
57
|
+
- Contributing to the open-source project itself
|
|
58
|
+
|
|
59
|
+
### 5. Commercial Use
|
|
60
|
+
|
|
61
|
+
"Commercial use" means any use that is primarily intended for or
|
|
62
|
+
directed toward commercial advantage or monetary compensation.
|
|
63
|
+
Examples of commercial use include:
|
|
64
|
+
|
|
65
|
+
- Selling the software or derivatives thereof
|
|
66
|
+
- Offering the software as a paid or ad-supported service
|
|
67
|
+
- Using the software in a commercial print farm or production
|
|
68
|
+
environment
|
|
69
|
+
- Embedding the software in a commercial product
|
|
70
|
+
- Using the software internally by a business to generate revenue
|
|
71
|
+
|
|
72
|
+
For commercial use, contact theapk llc to obtain a commercial
|
|
73
|
+
license: https://theapk.com or support@theapk.com
|
|
74
|
+
|
|
75
|
+
### 6. Conditions
|
|
76
|
+
|
|
77
|
+
You must include a copy of this license with every copy of the
|
|
78
|
+
software you distribute. You must include the copyright notice
|
|
79
|
+
above in all copies.
|
|
80
|
+
|
|
81
|
+
### 7. No Warranty
|
|
82
|
+
|
|
83
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
84
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
85
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
86
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
|
|
87
|
+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
88
|
+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
89
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
90
|
+
Requires-Python: >=3.10
|
|
91
|
+
Description-Content-Type: text/markdown
|
|
92
|
+
License-File: LICENSE
|
|
93
|
+
Requires-Dist: numpy>=1.24
|
|
94
|
+
Requires-Dist: numpy-stl>=3.0
|
|
95
|
+
Requires-Dist: trimesh>=4.0
|
|
96
|
+
Provides-Extra: test
|
|
97
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
98
|
+
Dynamic: license-file
|
|
99
|
+
|
|
100
|
+
# ghostprint
|
|
101
|
+
|
|
102
|
+
> Two-layer invisible watermark for 3D-printed parts.
|
|
103
|
+
> Forensics, not DRM. Free for noncommercial use + hosted web version.
|
|
104
|
+
|
|
105
|
+
[](LICENSE)
|
|
106
|
+
[]()
|
|
107
|
+
[](https://github.com/theapk/ghostprint/actions/workflows/test.yml)
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## What it does
|
|
112
|
+
|
|
113
|
+
Once a 3D-print customer has the STL, you can't stop them from copying it forever. What you can do is prove the part they printed came from your STL.
|
|
114
|
+
|
|
115
|
+
ghostprint adds two independent invisible watermarks to your workflow:
|
|
116
|
+
|
|
117
|
+
- **Layer 1 — G-code watermark.** A 12-byte payload (printer + job + timestamp) encoded into sub-resolution Z-babysteps at the start of a sliced G-code file, duplicated in a `;` comment block. It lives in the G-code, not the STL. Recover it from a sliced file with `python verify-print.py decode-gcode <file.gcode>` (prints printer/job/timestamp JSON). Survives any slicer that doesn't strip comments.
|
|
118
|
+
- **Layer 2 — Geometric steganography.** Per-vertex perturbation whose amplitude the tagger picks inside the allowed ±0.005–0.020 mm range (default 0.012 mm), driven by a BLAKE2b hash of the order ID. Smaller than a typical 0.04 mm nozzle X/Y resolution. Translation-invariant. **Not** invariant under rotation or rescaling, and it does **not** survive re-meshing (standard slicers re-mesh).
|
|
119
|
+
|
|
120
|
+
Later, if a suspect part shows up, drop the original STL back in and ghostprint tells you whether it matches.
|
|
121
|
+
|
|
122
|
+
## Demo
|
|
123
|
+
|
|
124
|
+

|
|
125
|
+
|
|
126
|
+
*Above: the hosted drag-drop web flow — the server runs the same tagging code and produces both layers there. In the CLI, L1 lives in G-code, not the STL (see the real CLI outputs in Use).*
|
|
127
|
+
|
|
128
|
+
## Install
|
|
129
|
+
|
|
130
|
+
Not on PyPI yet. Install from the repo:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
git clone https://github.com/theapk/ghostprint.git
|
|
134
|
+
cd ghostprint
|
|
135
|
+
python3 -m venv .venv
|
|
136
|
+
source .venv/bin/activate
|
|
137
|
+
|
|
138
|
+
pip install -r requirements.txt # CLI scripts: tag-print.py, verify-print.py
|
|
139
|
+
# or, for the `ghostprint` console command:
|
|
140
|
+
pip install -e .
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The `ghostprint` command exposes four verbs: `tag`, `verify`, `decode-gcode`, `self-test`.
|
|
144
|
+
|
|
145
|
+
## Use
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Tag an STL with order metadata
|
|
149
|
+
python tag-print.py master.stl \
|
|
150
|
+
--order-id ORDER-2026-0001 \
|
|
151
|
+
--printer bambucco-1 \
|
|
152
|
+
--job-seq 42 \
|
|
153
|
+
--out tagged.stl
|
|
154
|
+
|
|
155
|
+
# → writes tagged.stl + tagged.stl.manifest.json (plain JSON, unsigned —
|
|
156
|
+
# bookkeeping only; the watermark itself is the proof).
|
|
157
|
+
# L1 needs G-code: add --sliced-gcode your.gcode (splice into existing
|
|
158
|
+
# slices) or --emit-gcode (standalone watermarked G-code).
|
|
159
|
+
# `ghostprint tag` takes the same arguments.
|
|
160
|
+
|
|
161
|
+
# Later, verify a tagged part against its master (master first, tagged
|
|
162
|
+
# second — matching the original `ghostprint verify master.stl tagged.stl`
|
|
163
|
+
# promise; the sidecar manifest is auto-discovered next to the tagged part):
|
|
164
|
+
ghostprint verify master.stl tagged.stl
|
|
165
|
+
# … per-vertex diff report …
|
|
166
|
+
# → ✅ L2 match: order_id=ORDER-2026-0001 printer_id=15777188
|
|
167
|
+
# printer_id is the 24-bit ID hashed from the printer name, supplied by
|
|
168
|
+
# the sidecar manifest; no match line without it (pass --order-id instead).
|
|
169
|
+
|
|
170
|
+
# Recover the L1 layer from a G-code file — separate from STL verify,
|
|
171
|
+
# because L1 lives in the G-code, not the STL:
|
|
172
|
+
python verify-print.py decode-gcode tagged.gcode
|
|
173
|
+
# → {"printer_id": 15777188, "job_seq": 42, "ts_unix": 1795119073,
|
|
174
|
+
# "ts_iso": "2026-11-19T20:11:13Z", "source": "comment"}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Drag-drop web version
|
|
178
|
+
|
|
179
|
+
If you don't want to install Python, there's a hosted version:
|
|
180
|
+
|
|
181
|
+
**👉 https://ghostprint.theapk.com**
|
|
182
|
+
|
|
183
|
+
Three steps. No account required for the free tier. The web version uses the same CLI underneath — `tag-print.py` is the source of truth.
|
|
184
|
+
|
|
185
|
+
## Pricing (hosted version)
|
|
186
|
+
|
|
187
|
+
| Tier | Price | What you get |
|
|
188
|
+
|---|---|---|
|
|
189
|
+
| CLI | **Free** | Python, no upload, no tracking. Free for noncommercial use; commercial use requires a license. |
|
|
190
|
+
| Maker | $9/mo | Drag-drop web tool, hold master STLs in your account |
|
|
191
|
+
| Studio | $49/mo | Unlimited tags, multi-printer fleet dashboard, API access |
|
|
192
|
+
|
|
193
|
+
## Architecture
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
┌──────────────────┐
|
|
197
|
+
master.stl ───▶ │ │
|
|
198
|
+
│ tag-print.py │ ───▶ tagged.stl + <out>.manifest.json
|
|
199
|
+
--order-id ──▶ │ │ (plain JSON, unsigned)
|
|
200
|
+
--printer ──▶ │ │
|
|
201
|
+
--job-seq ──▶ │ │
|
|
202
|
+
└──────────────────┘
|
|
203
|
+
|
|
204
|
+
suspect.stl ─┐
|
|
205
|
+
├──▶ verify ───▶ ✅ / ❌ + extracted metadata
|
|
206
|
+
master.stl ──┘
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Both layers are written by `tag-print.py`. L1 needs G-code: give it `--sliced-gcode` (splice the watermark into existing slices) or `--emit-gcode` (standalone watermarked G-code); with neither, the L1 parameters are recorded in the manifest only. No network, no GPU. The L2 loop is pure Python — tagging a 50 MB STL takes ~1 min today; a vectorized fast path is planned.
|
|
210
|
+
|
|
211
|
+
## What it's not
|
|
212
|
+
|
|
213
|
+
- **Not DRM.** Can't stop someone from copying. Can't stop someone from stripping the watermark.
|
|
214
|
+
- **Not encryption.** Anyone with the original STL can extract the watermark. That's the point.
|
|
215
|
+
- **Not visible.** L2 perturbs vertices below typical print resolution; L1 rides inside the G-code text. Neither shows up on the part.
|
|
216
|
+
|
|
217
|
+
It's forensics. Think "document fingerprinting", not "encryption".
|
|
218
|
+
|
|
219
|
+
## Limitations
|
|
220
|
+
|
|
221
|
+
- L1 requires the G-code, not the STL. If the slicer strips `;` comments (very rare), only L2 survives.
|
|
222
|
+
- L2 is translation-invariant only. It does **not** survive rotation, rescaling, or re-meshing (standard slicers re-mesh — verify against the original master or a no-slicer path). Large temperature warp can shift vertices beyond the perturbation amplitude and break the match.
|
|
223
|
+
- No support for AMF, 3MF, or OBJ yet. PRs welcome.
|
|
224
|
+
|
|
225
|
+
## License
|
|
226
|
+
|
|
227
|
+
PolyForm Noncommercial 1.0.0 — free for personal, educational, and research use. Commercial use (selling the software, offering it as a paid service, using it in a commercial print farm) requires a separate license from theapk llc. See [LICENSE](LICENSE) for full terms.
|
|
228
|
+
|
|
229
|
+
## Author
|
|
230
|
+
|
|
231
|
+
Ian Schwartz — [@studiozeroseven](https://github.com/studiozeroseven) — [theapk llc](https://theapk.com)
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
**If you're selling 3D prints and want to catch knockoffs, this is for you.**
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# ghostprint
|
|
2
|
+
|
|
3
|
+
> Two-layer invisible watermark for 3D-printed parts.
|
|
4
|
+
> Forensics, not DRM. Free for noncommercial use + hosted web version.
|
|
5
|
+
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[]()
|
|
8
|
+
[](https://github.com/theapk/ghostprint/actions/workflows/test.yml)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## What it does
|
|
13
|
+
|
|
14
|
+
Once a 3D-print customer has the STL, you can't stop them from copying it forever. What you can do is prove the part they printed came from your STL.
|
|
15
|
+
|
|
16
|
+
ghostprint adds two independent invisible watermarks to your workflow:
|
|
17
|
+
|
|
18
|
+
- **Layer 1 — G-code watermark.** A 12-byte payload (printer + job + timestamp) encoded into sub-resolution Z-babysteps at the start of a sliced G-code file, duplicated in a `;` comment block. It lives in the G-code, not the STL. Recover it from a sliced file with `python verify-print.py decode-gcode <file.gcode>` (prints printer/job/timestamp JSON). Survives any slicer that doesn't strip comments.
|
|
19
|
+
- **Layer 2 — Geometric steganography.** Per-vertex perturbation whose amplitude the tagger picks inside the allowed ±0.005–0.020 mm range (default 0.012 mm), driven by a BLAKE2b hash of the order ID. Smaller than a typical 0.04 mm nozzle X/Y resolution. Translation-invariant. **Not** invariant under rotation or rescaling, and it does **not** survive re-meshing (standard slicers re-mesh).
|
|
20
|
+
|
|
21
|
+
Later, if a suspect part shows up, drop the original STL back in and ghostprint tells you whether it matches.
|
|
22
|
+
|
|
23
|
+
## Demo
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
*Above: the hosted drag-drop web flow — the server runs the same tagging code and produces both layers there. In the CLI, L1 lives in G-code, not the STL (see the real CLI outputs in Use).*
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
Not on PyPI yet. Install from the repo:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git clone https://github.com/theapk/ghostprint.git
|
|
35
|
+
cd ghostprint
|
|
36
|
+
python3 -m venv .venv
|
|
37
|
+
source .venv/bin/activate
|
|
38
|
+
|
|
39
|
+
pip install -r requirements.txt # CLI scripts: tag-print.py, verify-print.py
|
|
40
|
+
# or, for the `ghostprint` console command:
|
|
41
|
+
pip install -e .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The `ghostprint` command exposes four verbs: `tag`, `verify`, `decode-gcode`, `self-test`.
|
|
45
|
+
|
|
46
|
+
## Use
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Tag an STL with order metadata
|
|
50
|
+
python tag-print.py master.stl \
|
|
51
|
+
--order-id ORDER-2026-0001 \
|
|
52
|
+
--printer bambucco-1 \
|
|
53
|
+
--job-seq 42 \
|
|
54
|
+
--out tagged.stl
|
|
55
|
+
|
|
56
|
+
# → writes tagged.stl + tagged.stl.manifest.json (plain JSON, unsigned —
|
|
57
|
+
# bookkeeping only; the watermark itself is the proof).
|
|
58
|
+
# L1 needs G-code: add --sliced-gcode your.gcode (splice into existing
|
|
59
|
+
# slices) or --emit-gcode (standalone watermarked G-code).
|
|
60
|
+
# `ghostprint tag` takes the same arguments.
|
|
61
|
+
|
|
62
|
+
# Later, verify a tagged part against its master (master first, tagged
|
|
63
|
+
# second — matching the original `ghostprint verify master.stl tagged.stl`
|
|
64
|
+
# promise; the sidecar manifest is auto-discovered next to the tagged part):
|
|
65
|
+
ghostprint verify master.stl tagged.stl
|
|
66
|
+
# … per-vertex diff report …
|
|
67
|
+
# → ✅ L2 match: order_id=ORDER-2026-0001 printer_id=15777188
|
|
68
|
+
# printer_id is the 24-bit ID hashed from the printer name, supplied by
|
|
69
|
+
# the sidecar manifest; no match line without it (pass --order-id instead).
|
|
70
|
+
|
|
71
|
+
# Recover the L1 layer from a G-code file — separate from STL verify,
|
|
72
|
+
# because L1 lives in the G-code, not the STL:
|
|
73
|
+
python verify-print.py decode-gcode tagged.gcode
|
|
74
|
+
# → {"printer_id": 15777188, "job_seq": 42, "ts_unix": 1795119073,
|
|
75
|
+
# "ts_iso": "2026-11-19T20:11:13Z", "source": "comment"}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Drag-drop web version
|
|
79
|
+
|
|
80
|
+
If you don't want to install Python, there's a hosted version:
|
|
81
|
+
|
|
82
|
+
**👉 https://ghostprint.theapk.com**
|
|
83
|
+
|
|
84
|
+
Three steps. No account required for the free tier. The web version uses the same CLI underneath — `tag-print.py` is the source of truth.
|
|
85
|
+
|
|
86
|
+
## Pricing (hosted version)
|
|
87
|
+
|
|
88
|
+
| Tier | Price | What you get |
|
|
89
|
+
|---|---|---|
|
|
90
|
+
| CLI | **Free** | Python, no upload, no tracking. Free for noncommercial use; commercial use requires a license. |
|
|
91
|
+
| Maker | $9/mo | Drag-drop web tool, hold master STLs in your account |
|
|
92
|
+
| Studio | $49/mo | Unlimited tags, multi-printer fleet dashboard, API access |
|
|
93
|
+
|
|
94
|
+
## Architecture
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
┌──────────────────┐
|
|
98
|
+
master.stl ───▶ │ │
|
|
99
|
+
│ tag-print.py │ ───▶ tagged.stl + <out>.manifest.json
|
|
100
|
+
--order-id ──▶ │ │ (plain JSON, unsigned)
|
|
101
|
+
--printer ──▶ │ │
|
|
102
|
+
--job-seq ──▶ │ │
|
|
103
|
+
└──────────────────┘
|
|
104
|
+
|
|
105
|
+
suspect.stl ─┐
|
|
106
|
+
├──▶ verify ───▶ ✅ / ❌ + extracted metadata
|
|
107
|
+
master.stl ──┘
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Both layers are written by `tag-print.py`. L1 needs G-code: give it `--sliced-gcode` (splice the watermark into existing slices) or `--emit-gcode` (standalone watermarked G-code); with neither, the L1 parameters are recorded in the manifest only. No network, no GPU. The L2 loop is pure Python — tagging a 50 MB STL takes ~1 min today; a vectorized fast path is planned.
|
|
111
|
+
|
|
112
|
+
## What it's not
|
|
113
|
+
|
|
114
|
+
- **Not DRM.** Can't stop someone from copying. Can't stop someone from stripping the watermark.
|
|
115
|
+
- **Not encryption.** Anyone with the original STL can extract the watermark. That's the point.
|
|
116
|
+
- **Not visible.** L2 perturbs vertices below typical print resolution; L1 rides inside the G-code text. Neither shows up on the part.
|
|
117
|
+
|
|
118
|
+
It's forensics. Think "document fingerprinting", not "encryption".
|
|
119
|
+
|
|
120
|
+
## Limitations
|
|
121
|
+
|
|
122
|
+
- L1 requires the G-code, not the STL. If the slicer strips `;` comments (very rare), only L2 survives.
|
|
123
|
+
- L2 is translation-invariant only. It does **not** survive rotation, rescaling, or re-meshing (standard slicers re-mesh — verify against the original master or a no-slicer path). Large temperature warp can shift vertices beyond the perturbation amplitude and break the match.
|
|
124
|
+
- No support for AMF, 3MF, or OBJ yet. PRs welcome.
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
PolyForm Noncommercial 1.0.0 — free for personal, educational, and research use. Commercial use (selling the software, offering it as a paid service, using it in a commercial print farm) requires a separate license from theapk llc. See [LICENSE](LICENSE) for full terms.
|
|
129
|
+
|
|
130
|
+
## Author
|
|
131
|
+
|
|
132
|
+
Ian Schwartz — [@studiozeroseven](https://github.com/studiozeroseven) — [theapk llc](https://theapk.com)
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
**If you're selling 3D prints and want to catch knockoffs, this is for you.**
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "theapk-ghostprint"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Two-layer invisible watermark for 3D-printed parts (forensics, not DRM)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
authors = [{ name = "theapk llc" }]
|
|
13
|
+
dependencies = ["numpy>=1.24", "numpy-stl>=3.0", "trimesh>=4.0"]
|
|
14
|
+
|
|
15
|
+
[project.optional-dependencies]
|
|
16
|
+
test = ["pytest>=7.0"]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
ghostprint = "ghostprint.cli:main"
|
|
20
|
+
|
|
21
|
+
[tool.setuptools]
|
|
22
|
+
package-dir = { "" = "src" }
|
|
23
|
+
packages = ["ghostprint"]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""ghostprint — two-layer invisible watermark for 3D-printed parts (v0.1.1).
|
|
2
|
+
|
|
3
|
+
Layer 1 (L1): G-code micro-watermark (printer_id + job_seq + timestamp).
|
|
4
|
+
Layer 2 (L2): geometric steganography (order_id -> vertex perturbations).
|
|
5
|
+
|
|
6
|
+
The implementation lives in :mod:`ghostprint.core`; the tag/verify CLIs
|
|
7
|
+
live in tag-print.py / verify-print.py (repo clone layout), and
|
|
8
|
+
:mod:`ghostprint.cli` exposes the ``ghostprint`` console script.
|
|
9
|
+
|
|
10
|
+
Version matches ``theapk-ghostprint`` in pyproject.toml (0.1.1).
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from .core import * # noqa: F401,F403
|
|
14
|
+
from .core import ( # noqa: F401
|
|
15
|
+
GhostprintManifest,
|
|
16
|
+
L1_PREAMBLE,
|
|
17
|
+
L1_SCHEME_VERSION,
|
|
18
|
+
L2_AMPLITUDE_MAX_MM,
|
|
19
|
+
L2_AMPLITUDE_MIN_MM,
|
|
20
|
+
file_sha256,
|
|
21
|
+
l1_babysteps_to_payload,
|
|
22
|
+
l1_decode_payload,
|
|
23
|
+
l1_encode_payload,
|
|
24
|
+
l1_extract_from_gcode,
|
|
25
|
+
l1_payload_to_babysteps,
|
|
26
|
+
l1_rewrite_gcode,
|
|
27
|
+
l2_order_hash,
|
|
28
|
+
l2_perturb_vertices,
|
|
29
|
+
l2_recover_deltas,
|
|
30
|
+
l2_recover_order,
|
|
31
|
+
l2_verify_match,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
__version__ = "0.1.1"
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""ghostprint — console-script CLI for the two-layer 3D-print watermark.
|
|
2
|
+
|
|
3
|
+
Verbs (wrapping the repo's tag-print.py / verify-print.py):
|
|
4
|
+
ghostprint tag <tag-print.py arguments>
|
|
5
|
+
ghostprint verify <master.stl> <tagged.stl> [--order-id ...]
|
|
6
|
+
(also accepts decode-stl / decode-gcode subverbs)
|
|
7
|
+
ghostprint decode-gcode <FILE.gcode>
|
|
8
|
+
ghostprint self-test
|
|
9
|
+
|
|
10
|
+
v0.1.1 limitation: the CLI loads the sibling tag-print.py / verify-print.py
|
|
11
|
+
from a repo clone (documented install path: `pip install -e .` from the
|
|
12
|
+
git checkout). If the sibling scripts are missing (installed from a
|
|
13
|
+
wheel), main() fails cleanly with exit code 2.
|
|
14
|
+
"""
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import argparse
|
|
18
|
+
import importlib.util
|
|
19
|
+
import sys
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
from typing import List, Optional
|
|
22
|
+
|
|
23
|
+
_SRC_DIR = Path(__file__).resolve().parents[1] # <repo>/src (package lives in src/)
|
|
24
|
+
_REPO_ROOT = _SRC_DIR.parent # <repo>/ (sibling scripts live here)
|
|
25
|
+
_TAG_PRINT = _REPO_ROOT / "tag-print.py"
|
|
26
|
+
_VERIFY_PRINT = _REPO_ROOT / "verify-print.py"
|
|
27
|
+
|
|
28
|
+
_VERIFY_SUBVERBS = ("decode-gcode", "decode-stl", "self-test")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _load_sibling(module_name: str, path: Path):
|
|
32
|
+
"""Load a sibling repo script by absolute path (same house pattern as
|
|
33
|
+
landing/serve.py). Returns None when the script is missing, so the
|
|
34
|
+
installed-from-wheel case can fail cleanly in main()."""
|
|
35
|
+
if not path.exists():
|
|
36
|
+
return None
|
|
37
|
+
src = str(_SRC_DIR)
|
|
38
|
+
if src not in sys.path:
|
|
39
|
+
sys.path.insert(0, src)
|
|
40
|
+
spec = importlib.util.spec_from_file_location(module_name, path)
|
|
41
|
+
assert spec is not None and spec.loader is not None, f"cannot load {path}"
|
|
42
|
+
module = importlib.util.module_from_spec(spec)
|
|
43
|
+
sys.modules[module_name] = module
|
|
44
|
+
spec.loader.exec_module(module)
|
|
45
|
+
return module
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _verify_argv(rest: List[str]) -> List[str]:
|
|
49
|
+
"""Map `ghostprint verify ...` onto verify-print.py's argv.
|
|
50
|
+
|
|
51
|
+
Two-positional form (MASTER TAGGED — the README promise order) is
|
|
52
|
+
translated — decode-stl spells the master as --master. Everything else
|
|
53
|
+
passes through unchanged, and a leading verify-print.py subverb
|
|
54
|
+
(decode-gcode / decode-stl / self-test) is routed as-is.
|
|
55
|
+
"""
|
|
56
|
+
if rest and rest[0] in _VERIFY_SUBVERBS:
|
|
57
|
+
return rest
|
|
58
|
+
if rest and rest[0].startswith("-"):
|
|
59
|
+
# Flags-first ordering (--amplitude X / --manifest m.json BEFORE the
|
|
60
|
+
# positionals) can't be translated positionally: pass through and let
|
|
61
|
+
# decode-stl's argparse produce its clean required-argument error.
|
|
62
|
+
return ["decode-stl"] + rest
|
|
63
|
+
if len(rest) >= 2 and not rest[1].startswith("-"):
|
|
64
|
+
# README promise order: MASTER first, TAGGED second; decode-stl
|
|
65
|
+
# spells the master as --master and takes the TAGGED path as its
|
|
66
|
+
# suspect positional (so <tagged>.manifest.json auto-discovery
|
|
67
|
+
# keys on the tagged file).
|
|
68
|
+
return ["decode-stl", rest[1], "--master", rest[0]] + rest[2:]
|
|
69
|
+
return ["decode-stl"] + rest
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
73
|
+
ap = argparse.ArgumentParser(
|
|
74
|
+
prog="ghostprint",
|
|
75
|
+
description="ghostprint — two-layer invisible watermark for 3D-printed parts",
|
|
76
|
+
)
|
|
77
|
+
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
78
|
+
|
|
79
|
+
tag = sub.add_parser("tag", help="tag an STL: invisible fingerprint encoder (tag-print.py arguments)")
|
|
80
|
+
tag.add_argument("tag_args", nargs=argparse.REMAINDER, help=argparse.SUPPRESS)
|
|
81
|
+
|
|
82
|
+
verify = sub.add_parser("verify", help="compare a TAGGED part against a "
|
|
83
|
+
"MASTER (arguments: MASTER TAGGED; "
|
|
84
|
+
"or decode-stl/decode-gcode subverbs)")
|
|
85
|
+
verify.add_argument("verify_args", nargs=argparse.REMAINDER, help=argparse.SUPPRESS)
|
|
86
|
+
|
|
87
|
+
dg = sub.add_parser("decode-gcode", help="recover the L1 (printer+job+ts) payload from a G-code file")
|
|
88
|
+
dg.add_argument("decode_gcode_args", nargs=argparse.REMAINDER, help=argparse.SUPPRESS)
|
|
89
|
+
|
|
90
|
+
sub.add_parser("self-test", help="generate a cube, tag, decode both layers, assert round-trip")
|
|
91
|
+
return ap
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def main(argv: Optional[List[str]] = None) -> int:
|
|
95
|
+
ap = build_parser()
|
|
96
|
+
args = ap.parse_args(argv)
|
|
97
|
+
|
|
98
|
+
tag_mod = _load_sibling("gp_tag_print", _TAG_PRINT)
|
|
99
|
+
verify_mod = _load_sibling("gp_verify_print", _VERIFY_PRINT)
|
|
100
|
+
if tag_mod is None or verify_mod is None:
|
|
101
|
+
print("ghostprint CLI verbs require a repo clone for now — reinstall from git",
|
|
102
|
+
file=sys.stderr)
|
|
103
|
+
return 2
|
|
104
|
+
|
|
105
|
+
if args.cmd == "tag":
|
|
106
|
+
return tag_mod.main(args.tag_args)
|
|
107
|
+
if args.cmd == "verify":
|
|
108
|
+
return verify_mod.main(_verify_argv(args.verify_args))
|
|
109
|
+
if args.cmd == "decode-gcode":
|
|
110
|
+
return verify_mod.main(["decode-gcode"] + args.decode_gcode_args)
|
|
111
|
+
if args.cmd == "self-test":
|
|
112
|
+
return verify_mod.main(["self-test"])
|
|
113
|
+
ap.error(f"unknown command: {args.cmd}") # unreachable: subparsers are required
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
if __name__ == "__main__":
|
|
117
|
+
sys.exit(main())
|