Ghost Analysis
sigil_watermark.ghost.spectral_analysis
Ghost signature spectral analysis.
Analyzes images for traces of an author's spectral fingerprint — the "ghost" that propagates through AI model training.
The ghost signal uses multiplicative magnitude modulation at specific frequency bands. Extraction uses spectral whitening (normalizing by local magnitude) to detect the ±modulation pattern regardless of image content. This is robust to natural images with complex spectra.
GhostAnalysisResult
dataclass
Result of ghost signature spectral analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
ghost_detected |
bool
|
|
correlation |
float
|
Normalized correlation between whitened spectrum and expected ghost PN pattern. Higher values indicate stronger signal. |
band_energies |
dict[float, float]
|
Average spectral magnitude at each ghost frequency band, keyed by normalized frequency. |
p_value |
float
|
Statistical significance under the null hypothesis of no watermark. Combined across channels via Fisher's method for RGB inputs. |
ghost_hash |
list[int] | None
|
Extracted ghost hash bits (blind, no author key needed),
or |
Source code in src/sigil_watermark/ghost/spectral_analysis.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
extract_ghost_hash(image, config=DEFAULT_CONFIG)
Extract ghost hash bits from an image (blind, no key needed).
Detects multiplicative magnitude modulation at ghost frequency bands. Each hash bit's PN sign pattern produces a detectable modulation. Uses spectral whitening for robustness to natural image content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
ndarray
|
Grayscale (H,W) or RGB (H,W,3) image. |
required |
config
|
SigilConfig
|
Sigil configuration. |
DEFAULT_CONFIG
|
Returns:
| Type | Description |
|---|---|
list[int]
|
(hash_bits, confidences) where hash_bits is a list of 0/1 values |
list[float]
|
and confidences is a list of absolute correlation magnitudes. |
Source code in src/sigil_watermark/ghost/spectral_analysis.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
analyze_ghost_signature(image, public_key, config=DEFAULT_CONFIG)
Analyze a single image for ghost signature traces.
Uses the composite ghost PN (encoding the author's ghost hash bits) to measure correlation. Also extracts the ghost hash bits blindly. Supports both grayscale (H,W) and RGB (H,W,3) input — RGB channels are analyzed independently and averaged for sqrt(3) SNR improvement.
Source code in src/sigil_watermark/ghost/spectral_analysis.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
batch_analyze_ghost(images, public_key, config=DEFAULT_CONFIG)
Analyze multiple images for collective ghost signature.
More reliable than single-image analysis because the ghost signal is consistent across all images from the same author, while noise averages out.
Source code in src/sigil_watermark/ghost/spectral_analysis.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |