Manuscript Offprint
arXiv:2610.26102Provable Adversarial Detection: Prime Quantization meets Gromov--Wasserstein
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Adversarial vulnerability persists across modern vision architectures from CNNs to vision language models (VLMs), yet existing detection methods rely on heuristics without theoretical guarantees. We address the fundamental question of when adversarial perturbations can be provably detected from a geometric perspective. Our key insight is that adversarial perturbations cannot simultaneously preserve geometric structure across spaces with fundamentally different properties. Accordingly, we construct two such complementary metric spaces. First, we use a standard CNN embedding space Z, where adversarial samples exhibit significant displacement patterns. Second, we build a novel prime-quantized space P, that absorbs small perturbations through number-theoretic discretization, resulting in minimal displacement, while preserving discriminability. We then leverage the geometric discrepancies across spaces Z and P to detect adversarial samples. To the best of our knowledge, we establish the first rigorous separation theory for adversarial detection, proving that adversarial samples create unavoidable geometric inconsistencies across both spaces. Our framework provides theoretical guarantees including pixel-level absorption bounds, neighborhood diameter concentration, Gromov-Wasserstein (GW) separation theorems, and practical risk control. Extensive experiments validate our theoretical predictions and achieve consistently strong detection performance across a wide range of attack types and model families.
1 Introduction
Vision systems have rapidly progressed from CNNs He et al. (2016) to Vision–Language Models (VLMs) Radford et al. (2021) and multimodal architectures Hurst et al. (2024), yet adversarial vulnerability persists across all these paradigms. As these increasingly capable models are deployed at scale, the consequences of undetected adversarial attacks also scale, making detection a core safety requirement.
Defenses fall into three main families. Adversarial training (Madry et al., 2018; Zhang et al., 2019; Gowal et al., 2021) augments models with adversarial examples. While effective in restricted scenarios, it requires expensive retraining and often fails to generalize across diverse attacks, including gradient-based (Goodfellow et al., 2014; Madry et al., 2018; Carlini & Wagner, 2017), physical (Brown et al., 2017), and natural corruptions (Hendrycks & Dietterich, 2019b; Engstrom et al., 2019). Detection methods (Metzen et al., 2017; Feinman et al., 2017; Ma et al., 2018; Lee et al., 2018; Ma et al., 2019; Meng & Chen, 2017; Lee et al., 2024) rely on auxiliary classifiers or statistical tests, but remain heuristic and easily broken by adaptive adversaries (Athalye et al., 2018). Certifiable robustness (Raghunathan et al., 2018; Cohen et al., 2019; Salman et al., 2019) provides provable invariance regions, but targets robust classification rather than detection, and is computationally intensive. Trade-off frameworks such as TRADES (Zhang et al., 2019) deepened our theoretical understanding, but left unanswered the key question: “Can detection itself be endowed with guarantees, and what properties make adversarial examples inherently detectable?”
Our insight. Clean and adversarial samples leave distinct geometric traces across two complementary spaces, namely, the CNN embedding space Z and a prime-quantized space P. In Z, clean samples form tight neighborhoods, while adversarial ones exhibit characteristic displacements that disrupt local structure. In P, each pixel is discretized by rounding to nearby primes under a secret bit mask, so small perturbations are either absorbed within prime gaps or forced into discrete jumps. This mechanism preserves overall discriminability yet creates systematic cross-space inconsistencies, making adversarial inputs detectable through geometric analysis.
To the best of our knowledge, we establish the first rigorous geometric separation theory for adversarial detection, spanning four levels of guarantees: (i) pixel-level absorption bounds proving when perturbations vanish in P or cross prime-gap boundaries, (ii) K-NN diameter envelopes showing clean and adversarial neighborhoods diverge differently in Z and P, (iii) cross-space separation theorems based on Gromov–Wasserstein (GW) distances that yield a non-vanishing gap scaling with dimension and perturbation strength, and (iv) risk control guarantees establishing that simple thresholding achieves bounded misclassification rates. Together, these results provide a principled foundation for adversarial detection, addressing the open question of when and why detection must succeed.
Contributions. (i) We introduce prime quantization, a cryptographically inspired discretization that generalizes across CNN, VLM, and multimodal architectures, and could extend to other one-way transforms. (ii) We present a unified theoretical framework proving that adversarial perturbations necessarily induce cross-space inconsistencies, with guarantees from pixel absorption up through GW-based separation. (iii) We empirically validate our method on a broad suite of attacks, VLM zero-shot settings, and adaptive adversaries, demonstrating consistent and strong performance compared to state-of-the-art defenses.
Detection methods include: (i) autoencoder-based reconstruction (MagNet (Meng & Chen, 2017), PixelDefend (Song et al., 2018)), (ii) distributional analysis (Mahalanobis (Lee et al., 2018)), (iii) prediction differences (Feature Squeezing (Xu et al., 2018)), and (iv) learned classifiers (MetaAdvDet (Ma et al., 2019)). These approaches remain heuristic and are routinely bypassed by adaptive adversaries, with no guarantees on when detection must succeed.
Robust training and certification methods such as adversarial training (Madry et al., 2018), TRADES (Zhang et al., 2019), and certified defenses based on randomized smoothing (Cohen et al., 2019) or patch-based strategies (Xiang et al., 2022) aim at robust classification rather than detection, often requiring retraining and incurring accuracy trade-offs.
In contrast, our work provides the first theoretical guarantees that adversarial perturbations create unavoidable cross-space inconsistencies, yielding a principled basis for detection with quantifiable confidence. Unlike most prior defenses, we further evaluate on vision–language models in zero-shot settings, highlighting robustness beyond CNN benchmarks.
3 Preliminaries
We introduce notation and the prime-quantized space used by our detector.
Let be images, each a flattened vector of normalized pixels with label ( ). A classifier (where is the feature extractor and the classification head) has embedding , with . With a slight abuse of notation, we also use to denote the ambient embedding space equipped with the Euclidean metric . Thus, each is both a row of the embedding matrix and a point in metric space .
Definition 1 (Adversarial perturbation). Given , a perturbation yields . It is -bounded if .
To defend against such perturbations, we transform images into a discrete prime space via three steps: (i) scale to integers, (ii) round to primes, and (iii) rescale.
Definition 2 (Scaling). For , let . Define and .
Definition 3 (Prime rounding). Given secret bit , map integer to the nearest prime in . If , where , then , .
Definition 4 (Prime quantization). The pixel transform is . Extending component-wise yields .
Example 1. For , gives , between 37 and 41. Then , . A perturbation 0.385 still maps to 38, hence quantization is unchanged.
Space transformation. maps images into discrete , where prime gaps and secret yield irregular, attacker-unpredictable rounding. Unlike uniform quantization, prime rounding introduces structured but unpredictable discretization.
Problem statement. Given , construct a detector by comparing and , ensuring w.h.p. that clean inputs agree across spaces while adversarial ones create detectable discrepancies.
4 Multiscale Gromov-Wasserstein (GW) adversarial detector
Our method compares neighborhood behaviors of samples across the embedding space Z and the prime-quantized space P, exploiting their complementary geometries.
Clean neighborhoods. In Z, clean samples cluster by class, so a sample's local neighborhood is dominated by its true label and its global neighborhood aligns with class centroids. In contrast, prime quantization scatters samples uniformly in P, destroying spatial coherence, resulting in neighborhoods that show nearly uniform label distributions without clustering.
Adversarial neighborhoods. In Z, adversarial samples jump from their true cluster toward a wrong class, shifting both local and global label distributions. In P, prime quantization often reduces the impact of small perturbations, depending on the quantization gaps and perturbation strength. Therefore, adversarial neighborhoods tend to resemble their clean counterparts more closely. This creates systematic cross-space discrepancies between Z and P.
We next formalize these ideas via neighborhood maps and quantify their mismatches using Gromov-Wasserstein (GW) distances.
Definition 5 (Neighborhood map and induced distributions). Let be a metric space. For a query and integer , a neighborhood

Figure 1: Geometry in Z (clusters) vs. P (dispersed).
map returns a set of reference points, defining local neighborhoods when corresponds to nearest neighbors or global neighborhoods when corresponds to class centroids. The corresponding spatial distribution is (i.e., the space of probability measures over ). If is a class-label map, the corresponding semantic distribution is defined by the pushforward .
The GW distance compares probability distributions that are supported on possibly distinct metric spaces via alignment.
Definition 6 (Gromov–Wasserstein Distance). Let and be metric measure spaces, and define . The squared Gromov–Wasserstein distance is
Here, denotes the set of couplings between and . The integral is taken over with respect to .
As exact computation of GW involves a quadratic assignment problem (QAP), which is NP-hard Loiola et al. (2007), several tractable relaxations have been proposed. We focus on the entropic Gromov–Wasserstein distance Peyré et al. (2016), defined as
Choice of scales (lo, gl). We use lo and gl as labels for two neighborhood scales. The lo scale corresponds to a local k-NN neighborhood of the query in Z and P. The gl scale corresponds to a global neighborhood induced by a fixed set of k-means centroids, computed offline on clean training data, which define the support for cross-space GW coupling. This local/global decomposition follows standard practice in GW-based analysis.
Algorithm. Our detector takes an image , extracts its CNN embedding and prime-quantized version , and compares neighborhoods at two scales (). For each scale, we compute (i) spatial distributions , (ii) semantic distributions , and derive , , and a semantic mismatch score , defined as the Jensen–Shannon divergence with . The resulting six-dimensional feature vector encodes cross-space discrepancies, which are classified by an SVM. Full pseudocode is provided in Algorithm 1 in Appendix J.1.
5 Geometric Foundations and Theoretical Guarantees
We begin by analyzing the stability of the prime quantization map , which is central to our cross-space detector. The key question is, "when does a perturbation vanish into quantization noise, and when does it inevitably alter the output?" Our results formalize two complementary phenomena: pixel-level local stability and image-level injectivity. Prime quantization related proofs are deferred to Appendix B. All our formal results are stated for local neighborhoods. While the framework naturally extends to global neighborhoods, we leave the full theoretical treatment of that case to future work.
5.1 Pixel-Level Absorption
The absorption radius (Definition 7) captures the largest perturbation at a pixel that leaves its quantized value unchanged.
Definition 7 (Absorption radius). For with , the absorption radius is .
Proposition 1 (Absorption guarantee). If , then for all bits .
Lemma 1 (Absorption bounds). For any , .
Remarks. These results formalize pixel-level stability: perturbations smaller than vanish under prime quantization, while larger ones necessarily cause a quantization change. Although Lemma 1 permits , practical values are tiny (e.g., for ). Since adversarial budgets in vision ( ) typically exceed these radii, most attacks cross prime boundaries and induce detectable discrepancies between Z and P.

Figure 2: Geometric inconsistency detection and gap theorem validation. 1st panel: clean neighborhoods; 2nd panel: adversarial separation ( ); 3rd panel: gap theorem across ; 4th panel: risk control thresholding (left:clean; right:adversarial).
Even when perturbations lie near or below , clean and adversarial samples seldom quantize identically. Because prime gaps are irregular, even a 1/255 change can cross a prime-interval midpoint under the same bit-vector b, yielding different prime assignments. And when some coordinates do round identically, the Z-space embedding remains sensitive while P stays piecewise constant, producing a measurable Z-P mismatch. Larger prime resolution k further shrinks and increases the likelihood of such discrepancies.
5.2 Image-Level Injectivity
While prime quantization is many-to-one per pixel, we must ensure it does not collapse distinct images globally. Lemma 2 shows that such collisions are exponentially unlikely.
Lemma 2 (Collision probability). Fix and let . Let be two independent random images with i.i.d. pixel marginals whose densities are bounded by on (in particular, for the uniform distribution). For a fixed secret bit vector , let be the prime-quantization transform (Definition 4). Assume the prime-gap envelope from Assumption 1. Then, . In particular, for , the collision probability decays as in the number of pixels.
Remarks. Lemma 2 establishes that global collisions are vanishingly rare. Even with pixel-level absorption, distinct images remain separable: e.g., for CIFAR-10 ( ) and , is effectively zero. Thus, quantization is locally many-to-one but globally almost injective, ensuring discriminability while dampening small perturbations.
5.3 Bridge to GW Separation
Pixel-level absorption (Def. 7, Prop. 1) and image-level injectivity (Lemma 2) set the boundary conditions: if , perturbations vanish in while still moves; if , quantization shifts and changes, so in both regimes and neighborhoods diverge. To formalize these divergences, we embed samples into spatial–semantic product spaces and , representing each image as and . By Theorem 5 and Corollary 2, the product is the tightest among admissible component metrics, so any discrepancy in geometry or label mass yields separation in and . This construction underlies the GW envelope and gap theorems that follow.
5.4 Diameter Envelopes in C and K
We now summarize the behavior of k-nearest neighbor diameters in the two product spaces C (CNN-based) and K (prime-quantized). For clean samples, diameters concentrate tightly around a median distance; for adversarially perturbed samples, explicit additive expansion terms appear. The full technical statements and proofs are deferred to Appendix D.
Lemma 3 (Unified local diameter envelopes in and ). For any confidences and local neighborhood size , and under the variance proxy (Assumption 2) and prime-gap sensitivity (Assumption 3) conditions (see Appendix D), define the clean envelopes as and . Additionally, we define the Jacobian drift as . Then, for clean queries and adversarial queries , the following bounds hold:
Here is the clean median pairwise distance in , is the maximum key-annealed median distance in , is the variance proxy from Assumption 2, and is the prime-gap sensitivity constant from Assumption 3.
Geometric Insight. In C, clean neighborhood diameters concentrate around a median distance (App. Lemma 6), while adversarial perturbations add a Jacobian-driven drift and a possible label-flip penalty. In K, clean neighborhoods are stabilized by prime-gap sensitivity (App. Thm. 8), whereas adversarial perturbations add terms from key sensitivity, perturbation norms, and label flips. Together these define the diameter envelopes that underlie the cross-space GW theorems. Fig. 2 (1st–2nd panels) empirically confirms this: clean samples form compact clusters consistent with App. Thms. 6, 8, while adversarial queries induce the predicted separation gap (Thm. 2).
5.5 GW Bounds: Clean vs. Adversarial
We now move from local geometry (K-NN diameter bounds in C and K, Lemma 3) to a distributional geometry comparison across spaces. The Gromov–Wasserstein (GW) distance aligns pairwise distance structures, allowing us to bound: (i) in the clean case, similarity of C and K, and (ii) in the adversarial case, a provable increase when perturbations inflate diameters differently across spaces. This separation underlies our detection framework.
Theorem 1 (Clean cross-space GW upper bound via K-NN radii). Fix a clean query x and consider its local neighborhoods and , each endowed with the uniform probability measure on K points.
Let and denote the clean K-NN radii in and , respectively. Assume the clean radius envelopes and hold with probabilities at least and , as established in Appendix D.
Then, with probability at least , the quadratic Gromov–Wasserstein discrepancy between the clean neighborhoods satisfies
Notation (adversarial queries, radii, and gap). For a clean input and perturbation , the adversarial query in is . Its nearest neighbors form with radii and maximum . We partition the neighbors into an inner set of size and outer set of size , and define the separation gap as .
Theorem 2 (Adversarial cross-space GW lower bound). Fix a query and perturbation , and consider the adversarial neighborhoods and , each with uniform measure on points. Let be the separation gap and let denote the adversarial -NN diameter in , bounded as in Appendix Theorem 9. Define the adversarial -diameter . Then, with probability at least ,
Full proof is provided in Appendix F.
Mirror results. For brevity, we omit the symmetric (i) clean lower bounds and (ii) adversarial upper bounds on GW, but detailed proofs are provided in Theorem 10 and Theorem 11 in Appendix F.
5.6 GW Gap and Risk Control
Theorem 3 (Cross-space GW gap). With probability at least , the clean and adversarial GW discrepancies satisfy , where and . Under Assumption 2, for fixed and perturbation , we obtain .
Lemma 4 (Risk control via GW margin). If the gap event holds with margin and an estimator satisfies , then thresholding at the midpoint between clean and adversarial envelopes makes no error on this event. Thus .
From GW to entropic GW. All bounds above were stated for quadratic . For entropic GW with , the lower bounds remain unchanged, while the upper bounds incur only an additive (Corollaries 7–8). Hence, the clean/adversarial separation guarantees extend seamlessly to the entropic case used in practice. Theorem 3 certifies a provable margin: the clean GW discrepancy is uniformly controlled by the clean envelopes, while adversarial perturbations induce a lower bound whose leading term scales as (up to constants). Lemma 4 translates this into a statistical guarantee: once concentrates within , thresholding achieves negligible error. Empirical evidence (Fig. 2, panel 4) confirms the theory: clean and adversarial discrepancy distributions separate cleanly, validating the predicted risk bound. Proofs and full derivations are in App. F.
6 Empirical Analysis
6.1 Experimental Setup
Adversarial Attacks. We evaluate a broad suite spanning gradient-based, optimization, spatial, and perceptual perturbations: Auto-Attack (AA) (Croce & Hein, 2020), Carlini–Wagner (CW) (Carlini & Wagner, 2017), Patch (PT) (Brown et al., 2017), Projected Gradient Descent (PGD) (Madry et al., 2018), Spatial (SA) (Engstrom et al., 2019), Square (SQ) (Andriushchenko et al., 2020), Universal Perturbations (UP) (Moosavi-Dezfooli et al., 2017), Auto-PGD (AP) (Croce & Hein, 2020), Fast Gradient Sign (FG) (Goodfellow et al., 2014), Frequency (FA) (Yin et al., 2019), Gaussian Blur (GB) (Zhang et al., 2022), Pixel Flip (PF) (Su et al., 2019), Semantic Rotation (SR) (Hosseini & Poovendran, 2018), AdvAD (AAD) (Li et al., 2024), Penalizing Gradient Norm (PGN) (Ge et al., 2023), and Block Shuffle and Rotation (BSR) (Wang et al., 2024). We use these boldface abbreviations throughout tables and figures for brevity. Refer to Table 5 in Appendix G.5 for attack hyperparameter settings and defaults.
Baseline Defenses. We benchmark against representative detection methods: Mahalanobis Detector (MD) (Lee et al., 2018), Feature Squeezing (FS) (Xu et al., 2018), Meta-Adversarial-Detect (MAD) (Ma et al., 2019), MagNet (MN) (Meng & Chen, 2017), Multiple Perturbation Detector (EA) (Zhang et al., 2023), and Be Your Own Neighborhood (BY) (He et al., 2024).
Evaluation Metrics. We report the following complementary metrics. (1) Binary detection accuracy: overall accuracy of classifying inputs as clean or adversarial. (2) True Positive Rate (TPR): fraction of adversarial samples correctly flagged as adversarial, i.e., . (3)
| Attack | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| AA | 97.9 | 68.9 | 82.7 | 52.0 | 74.1 |
| CW | 97.0 | 73.6 | 86.0 | 51.4 | 56.7 |
| PT | 98.0 | 86.4 | 67.8 | 50.7 | 57.3 |
| PGD | 97.8 | 91.3 | 74.4 | 51.1 | 81.0 |
| SA | 96.8 | 78.1 | 74.4 | 41.1 | 54.9 |
| SQ | 97.6 | 89.2 | 88.5 | 51.0 | 44.4 |
| UP | 97.8 | 66.4 | 53.7 | 50.7 | 47.9 |
| AP | 97.6 | 68.3 | 81.4 | 50.2 | 73.6 |
| FG | 98.0 | 73.8 | 60.9 | 49.6 | 44.7 |
| FA | 95.1 | 49.9 | 50.0 | 49.7 | 49.8 |
| GB | 85.7 | 49.8 | 51.7 | 48.2 | 48.6 |
| PF | 97.0 | 51.7 | 51.4 | 49.5 | 49.4 |
| SR | 95.9 | 50.3 | 52.7 | 50.1 | 49.1 |
Table 1: Binary detection accuracy (%). Best results are in bold and second best are underlined.
| Attack | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 0.97 | 0.91 | 0.71 | 0.25 | 0.78 | 0.96 | 0.70 |
| ViT | 0.95 | 0.65 | 0.75 | 0.57 | 0.01 | 0.95 | 0.80 | |
| SQ | ResNet-18 | 0.96 | 0.89 | 0.85 | 0.24 | 0.01 | 0.90 | 0.57 |
| ViT | 0.95 | 0.66 | 0.86 | 0.56 | 0.02 | 0.89 | 0.61 | |
| PT | ResNet-18 | 0.98 | 0.86 | 0.54 | 0.26 | 0.03 | 0.89 | 0.80 |
| ViT | 0.95 | 0.66 | 0.67 | 0.54 | 0.01 | 0.89 | 0.81 | |
| AAD | ResNet-18 | 0.95 | 0.31 | 0.46 | 0.52 | 0.13 | 0.91 | 0.59 |
| ViT | 0.93 | 0.67 | 0.57 | 0.64 | 0.01 | 0.92 | 0.82 | |
| PGN | ResNet-18 | 0.95 | 0.63 | 0.62 | 0.24 | 0.01 | 0.90 | 0.77 |
| ViT | 0.96 | 0.67 | 0.62 | 0.64 | 0.02 | 0.93 | 0.77 | |
| BSR | ResNet-18 | 0.95 | 0.67 | 0.52 | 0.23 | 0.40 | 0.92 | 0.81 |
| ViT | 0.98 | 0.67 | 0.56 | 0.64 | 0.02 | 0.92 | 0.78 |
Table 2: F1-score comparison on CIFAR-10 across multiple attacks using ResNet-18 and ViT. Best results are in bold, second best are underlined.
End-to-End accuracy: proportion of clean samples correctly classified and passed by the detector, plus adversarial samples correctly blocked; this reflects system-level robustness under attack. (4) Precision: fraction of samples flagged as adversarial that are truly adversarial. (5) Recall: identical to TPR—the fraction of adversarial samples correctly detected. (6) F1-score: harmonic mean of precision and recall, summarizing detection quality under imbalance. (7) AUROC: area under the ROC curve, measuring threshold-independent separability between clean and adversarial distributions.
6.2 Adversarial Detection Accuracy
Setup. We evaluate detection on the datasets CIFAR-10 Krizhevsky et al. (2009), FMNIST Xiao et al. (2017), KMNIST Clanuwat et al. (2018), and ImageNet Deng et al. (2009) using models ResNet18 He et al. (2016) and ViT Dosovitskiy et al. (2021), with adversarial datasets generated from the attack suite in Sec. 6.1. Detector/classifier hyperparameters and attack configurations appear in Appendix H and Appendix G.5, respectively. We note that ResNet18 on CIFAR-10 is employed as our default configuration.
Results and analysis.
Table 1 shows that our detector achieves binary detection on 12 of 13 attacks, with Gaussian blur (85.7%) as the only exception. Accuracy remains consistently high across attack families: (i) Gradient/optimization (AA, CW, PGD, AP): 96–98%, with margins of +10–20 points, since small-norm shifts in are often absorbed in , producing sharp cross-space mismatches; (ii) Spatial/patch (SA, PT): 97–98%, where local structural changes disrupt geometry differently in each space; (iii) Transfer/decision-based (SQ, UP): 97–98%, where transfer-induced distortions misalign and far more than gradient-based attacks, yielding especially large gains (+31 points on UP); and (iv) Perceptual/frequency (FA, PF, SR): 95–97%, where frequency and semantic shifts perturb 's discrete neighborhoods and 's embeddings in complementary ways, creating highly detectable discrepancies. Gaussian blur is the hardest case because it averages neighboring pixels, suppressing edges and textures, inducing similar distortions in both and . This reduces the cross-space discrepancy that our detector exploits. Nevertheless, uneven quantization in ensures residual separation, and we still outperform all baselines on blur. Full per-dataset results and additional metrics, including TPR/FPR heatmaps and end-to-end-accuracy, are reported in Table 12(Appendix K) and Appendix L respectively. Across all six attacks and both architectures (ResNet-18 and ViT), our method consistently achieves the highest F1-scores, typically exceeding 0.95. EA generally emerges as the strongest baseline yet remains noticeably weaker than our detector, especially under patch-based and structure-altering attacks such as SQ and PT. Modern attacks such as AAD, PGN, and BSR also show the same trend: while EA or BY occasionally achieve strong second-best performance, our approach maintains a clear advantage across architectures. These results highlight the robustness and model-agnostic behavior of the proposed Z–P discrepancy framework.
| Dataset | ||
|---|---|---|
| CIFAR-10 | 86.7 | 84.5 |
| FMNIST | 89.6 | 87.9 |
| KMNIST | 88.2 | 86.8 |
(a) Adaptive attack detection (%).
| Features | AA | CW | PT | PGD | FG |
|---|---|---|---|---|---|
| Local only | 67.7 | 76.2 | 73.2 | 62.5 | 79.1 |
| Global only | 83.5 | 66.5 | 75.6 | 65.0 | 71.3 |
| Both | 97.9 | 97.0 | 98.0 | 97.8 | 98.0 |
(b) Ablation on CIFAR-10 (%).
Table 3: Adaptive robustness and feature ablation. (a) Our method resists adaptive white-box attacks despite defense-aware optimization. (b) Combining local and global GW features yields the strongest detection across attacks.
6.3 Adaptive Attack Resistance and Ablation
Adaptive attacks. We test two white-box adaptive formulations: (i) cross-space () and (ii) multi-scale (), where the adversary knows the architecture but not the secret bit vector . The complete formulation of the adversary's objective, the prior distribution over unknown secret bits, the consistency penalties, and the optimization procedure are provided in Appendix I. As shown in Table 3a, our method maintains strong detection (84–90%) across CIFAR-10, FMNIST, and KMNIST, demonstrating robustness even when defenses are explicitly targeted. This accuracy drop relative to non-adaptive attacks arises because the adversary now explicitly optimizes to minimize cross-space discrepancies (CNN vs. crypto features). By enforcing feature consistency under a prior over , they can partially reduce the mismatches our detector relies on.
Ablation study. To quantify feature contributions, we compare detectors using only local GW features, only global GW features, or both. Table 3b shows that while local or global features alone yield moderate performance (65–83%), combining them achieves 97–98% across all attacks. This confirms that local fine-grained cues and global structural signals are complementary.
7 Conclusion
We introduced a principled framework for adversarial detection based on geometric inconsistencies between the embedding space Z and a prime-quantized space P. Our theory shows that adversarial perturbations inevitably create detectable cross-space discrepancies, providing the first guarantees for when detection must succeed. Experiments confirm consistently high detection accuracy across diverse attacks, strong generalization to zero-shot VLMs, and robustness to adaptive adversaries. These results demonstrate that geometric reasoning offers a solid foundation for adversarial robustness. An immediate direction is to adapt our framework to multimodal models, where both adversarial pressure and generalization demands are higher. Extending our theoretical guarantees from local to global neighborhoods also forms an interesting direction for future work.
8 Limitations and Scope:
The framework is most effective when perturbations induce non-isometric distortions between Z and P; approximately low-frequency or near-isometric transformations, such as Gaussian blur, produce weaker geometric discrepancies and reduced detection margins. In addition, the use of Gromov–Wasserstein distances incurs higher computational cost relative to simpler detectors (Appendix K.8), favoring high-assurance over ultra-low-latency deployments. The theoretical guarantees rely on explicit assumptions, including the validity of a local Jacobian proxy (Assumption 2) and neighborhood regularity, and should be interpreted as local geometric rather than global manifold-level results.
References
Maksym Andriushchenko, Francesco Croce, Nicolas Flammarion, and Matthias Hein. Square attack: a query-efficient black-box adversarial attack via random search. In European conference on computer vision, pp. 484–501. Springer, 2020.
Anish Athalye, Nicholas Carlini, and David Wagner. Obfuscated gradients give a false sense of security: Circumventing defenses to adversarial examples. In International conference on machine learning, pp. 274–283. PMLR, 2018.
Aharon Ben-Tal, Laurent El Ghaoui, and Arkadi Nemirovski. Robust Optimization. Princeton University Press, Princeton, NJ, 2009.
Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101–mining discriminative components with random forests. In European conference on computer vision, pp. 446–461. Springer, 2014.
Tom B Brown, Dandelion Mané, Aurko Roy, Martín Abadi, and Justin Gilmer. Adversarial patch. arXiv preprint arXiv:1712.09665, 2017.
Nicholas Carlini and David Wagner. Towards evaluating the robustness of neural networks. In 2017 IEEE Symposium on Security and Privacy (SP), pp. 39–57. IEEE Computer Society, 2017.
Pin-Yu Chen, Huan Zhang, Yash Sharma, Jinfeng Yi, and Cho-Jui Hsieh. Zoo: Zeroth order optimization based black-box attacks to deep neural networks without training substitute models. In Proceedings of the 10th ACM Workshop on Artificial Intelligence and Security, AISec '17, pp. 15–26. Association for Computing Machinery, 2017.
Tarin Clanuwat, Mikel Bober-Irizar, Asanobu Kitamoto, Alex Lamb, Kazuaki Yamamoto, and David Ha. Deep learning for classical Japanese literature. arXiv preprint arXiv:1812.01718, 2018.
Jeremy Cohen, Elan Rosenfeld, and Zico Kolter. Certified adversarial robustness via randomized smoothing. In international conference on machine learning, pp. 1310–1320. PMLR, 2019.
Francesco Croce and Matthias Hein. Reliable evaluation of adversarial robustness with an ensemble of diverse parameter-free attacks. In International conference on machine learning, pp. 2206–2216. PMLR, 2020.
Xuanming Cui, Alejandro Aparcedo, Young Kyun Jang, and Ser-Nam Lim. On the robustness of large multimodal models against image adversarial attacks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 24625–24634, 2024.
Herbert A David and Haikady N Nagaraja. Order statistics. John Wiley & Sons, 2004.
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009.
Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021.
Pierre Dusart. Estimates of some functions over primes without rh. arXiv preprint arXiv:1002.0442, 2010.
Logan Engstrom, Brandon Tran, Dimitris Tsipras, Ludwig Schmidt, and Aleksander Madry. Exploring the landscape of spatial robustness. In International conference on machine learning, pp. 1802–1811. PMLR, 2019.
Li Fei-Fei, Rob Fergus, and Pietro Perona. Learning generative visual models from few training examples: An incremental bayesian approach tested on 101 object categories. In 2004 conference on computer vision and pattern recognition workshop, pp. 178–178. IEEE, 2004.
Reuben Feinman, Ryan R Curtin, Saurabh Shintre, and Andrew B Gardner. Detecting adversarial samples from artifacts. arXiv preprint arXiv:1703.00410, 2017.
Zhijin Ge, Hongying Liu, Wang Xiaosen, Fanhua Shang, and Yuanyuan Liu. Boosting adversarial transferability by achieving flat local maxima. Advances in Neural Information Processing Systems, 36:70141–70161, 2023.
Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014.
Sven Gowal, Sylvestre-Alvise Rebuffi, Olivia Wiles, Florian Stimberg, Dan Andrei Calian, and Timothy A Mann. Improving robustness using generated data. Advances in neural information processing systems, 34:4218–4233, 2021.
Gregory Griffin, Alex Holub, Pietro Perona, et al. Caltech-256 object category dataset. Technical report, Technical Report 7694, California Institute of Technology Pasadena, 2007.
Godfrey Harold Hardy and Edward Maitland Wright. An introduction to the theory of numbers. Oxford university press, 1979.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016.
Zhiyuan He, Yijun Yang, Pin-Yu Chen, Qiang Xu, and Tsung-Yi Ho. Be your own neighborhood: Detecting adversarial examples by the neighborhood relations built on self-supervised learning. In Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pp. 18063–18080. PMLR, 21–27 Jul 2024.
Dan Hendrycks and Thomas Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. arXiv preprint arXiv:1903.12261, 2019a.
Dan Hendrycks and Thomas Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. In International Conference on Learning Representations, 2019b.
Hossein Hosseini and Radha Poovendran. Semantic adversarial examples. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops, pp. 1614–1619, 2018.
Aaron Hurst, Adam Lerer, Adam P Goucher, Adam Perelman, Aditya Ramesh, Aidan Clark, AJ Ostrow, Akila Welihinda, Alan Hayes, Alec Radford, et al. Gpt-4o system card. arXiv preprint arXiv:2410.21276, 2024.
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In Proceedings of the 32nd International Conference on Machine Learning, volume 37 of Proceedings of Machine Learning Research, pp. 448–456. PMLR, 07–09 Jul 2015.
Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
Anders Krogh and John Hertz. A simple weight decay can improve generalization. In J. Moody, S. Hanson, and R.P. Lippmann (eds.), Advances in Neural Information Processing Systems, volume 4. Morgan-Kaufmann, 1991.
Hyeyoon Lee, Kanghyun Choi, Dain Kwon, SunJong Park, Mayoore Selvarasa Jaiswal, Noseong Park, Jonghyun Choi, and Jinho Lee. Datafreeshield: Defending adversarial attacks without training data. In Forty-first International Conference on Machine Learning, 2024.
Kimin Lee, Kibok Lee, Honglak Lee, and Jinwoo Shin. A simple unified framework for detecting out-of-distribution samples and adversarial attacks. Advances in neural information processing systems, 31, 2018.
Jin Li, Ziqiang He, Anwei Luo, Jian-Fang Hu, Z Jane Wang, and Xiangui Kang. Advad: Exploring non-parametric diffusion for imperceptible adversarial attacks. Advances in Neural Information Processing Systems, 37:52323–52353, 2024.
Haotian Liu, Chunyuan Li, Qingyang Wu, and Yong Jae Lee. Visual instruction tuning. In Advances in Neural Information Processing Systems, volume 36, pp. 34892–34916. Curran Associates, Inc., 2023.
Eliane Maria Loiola, Nair Maria Maia de Abreu, Paulo Oswaldo Boaventura-Netto, Peter Hahn, and Tania Querido. A survey for the quadratic assignment problem. European Journal of Operational Research, 176(2):657–690, 2007. ISSN 0377-2217. doi: https://doi.org/10.1016/j.ejor.2005.09.032. URL https://www.sciencedirect.com/science/article/pii/S0377221705008337.
Chen Ma, Chenxu Zhao, Hailin Shi, Li Chen, Junhai Yong, and Dan Zeng. Metaadvdet: Towards robust detection of evolving adversarial attacks. pp. 692–701. Association for Computing Machinery, 2019.
Xingjun Ma, Bo Li, Yisen Wang, Sarah M. Erfani, Sudanthi Wijewickrema, Grant Schoenebeck, Michael E. Houle, Dawn Song, and James Bailey. Characterizing adversarial subspaces using local intrinsic dimensionality. In International Conference on Learning Representations, 2018.
Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. In International Conference on Learning Representations, 2018.
Dongyu Meng and Hao Chen. Magnet: a two-pronged defense against adversarial examples. In Proceedings of the 2017 ACM SIGSAC conference on computer and communications security, pp. 135–147, 2017.
Jan Hendrik Metzen, Tim Genewein, Volker Fischer, and Bastian Bischoff. On detecting adversarial perturbations. In International Conference on Learning Representations, 2017.
Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, Omar Fawzi, and Pascal Frossard. Universal adversarial perturbations. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1765–1773, 2017.
Gabriel Peyré, Marco Cuturi, and Justin Solomon. Gromov-wasserstein averaging of kernel and distance matrices. In International conference on machine learning, pp. 2664–2672. PMLR, 2016.
Ben Poole, Subhaneil Lahiri, Maithra Raghu, Jascha Sohl-Dickstein, and Surya Ganguli. Exponential expressivity in deep neural networks through transient chaos. Advances in neural information processing systems, 29, 2016.
Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International conference on machine learning, pp. 8748–8763. PMLR, 2021.
Aditi Raghunathan, Jacob Steinhardt, and Percy Liang. Certified defenses against adversarial examples. In International Conference on Learning Representations, 2018.
Reuven Y Rubinstein and Dirk P Kroese. Simulation and the Monte Carlo method. John Wiley & Sons, 2016.
Hadi Salman, Jerry Li, Ilya Razenshteyn, Pengchuan Zhang, Huan Zhang, Sebastien Bubeck, and Greg Yang. Provably robust deep learning via adversarially trained smoothed classifiers. In Advances in Neural Information Processing Systems, volume 32, 2019.
Shibani Santurkar, Dimitris Tsipras, Andrew Ilyas, and Aleksander Madry. How does batch normalization help optimization? Advances in neural information processing systems, 31, 2018.
Samuel S. Schoenholz, Justin Gilmer, Surya Ganguli, and Jascha Sohl-Dickstein. Deep information propagation. In International Conference on Learning Representations, 2017.
Yang Song, Taesup Kim, Sebastian Nowozin, Stefano Ermon, and Nate Kushman. Pixeldefend: Leveraging generative models to understand and defend against adversarial examples. In International Conference on Learning Representations, 2018.
Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: A simple way to prevent neural networks from overfitting. Journal of Machine Learning Research, 15(56):1929–1958, 2014.
Jiawei Su, Danilo Vasconcellos Vargas, and Kouichi Sakurai. One pixel attack for fooling deep neural networks. IEEE Transactions on Evolutionary Computation, 23(5):828–841, 2019.
Roman Vershynin. High-Dimensional Probability: An Introduction with Applications in Data Science. Cambridge Series in Statistical and Probabilistic Mathematics. Cambridge University Press, 2018.
Stefan Wager, Sida Wang, and Percy S Liang. Dropout training as adaptive regularization. In Advances in Neural Information Processing Systems, volume 26, 2013.
Kunyu Wang, Xuanran He, Wenxuan Wang, and Xiaosen Wang. Boosting adversarial transferability by block shuffle and rotation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 24336–24346, 2024.
Chong Xiang, Saeed Mahloujifar, and Prateek Mittal. Patchcleanser: Certifiably robust defense against adversarial patches for any image classifier. In 31st USENIX security symposium (USENIX Security 22), pp. 2065–2082, 2022.
Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms. arXiv preprint arXiv:1708.07747, 2017.
Weilin Xu, David Evans, and Yanjun Qi. Feature squeezing: Detecting adversarial examples in deep neural networks. In 25th Annual Network and Distributed System Security Symposium, NDSS 2018, San Diego, California, USA, February 18-21, 2018, 2018.
An Yang, Baosong Yang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Zhou, Chengpeng Li, Chengyuan Li, Dayiheng Liu, Fei Huang, Guanting Dong, Haoran Wei, Huan Lin, Jialong Tang, Jialin Wang, Jian Yang, Jianhong Tu, Jianwei Zhang, Jianxin Ma, Jianxin Yang, Jin Xu, Jingren Zhou, Jinze Bai, Jinzheng He, Junyang Lin, Kai Dang, Keming Lu, Keqin Chen, Kexin Yang, Mei Li, Mingfeng Xue, Na Ni, Pei Zhang, Peng Wang, Ru Peng, Rui Men, Ruize Gao, Runji Lin, Shijie Wang, Shuai Bai, Sinan Tan, Tianhang Zhu, Tianhao Li, Tianyu Liu, Wenbin Ge, Xiaodong Deng, Xiaohuan Zhou, Xingzhang Ren, Xinyu Zhang, Xipin Wei, Xuancheng Ren, Xuejing Liu, Yang Fan, Yang Yao, Yichang Zhang, Yu Wan, Yunfei Chu, Yuqiong Liu, Zeyu Cui, Zhenru Zhang, Zhifang Guo, and Zhihao Fan. Qwen2 technical report, 2024. URL https://arxiv.org/abs/2407.10671.
Dong Yin, Raphael Gontijo Lopes, Jon Shlens, Ekin Dogus Cubuk, and Justin Gilmer. A fourier perspective on model robustness in computer vision. Advances in Neural Information Processing Systems, 32, 2019.
Hongyang Zhang, Yaodong Yu, Jiantao Jiao, Eric Xing, Laurent El Ghaoui, and Michael Jordan. Theoretically principled trade-off between robustness and accuracy. In International conference on machine learning, pp. 7472–7482. PMLR, 2019.
Shuhai Zhang, Feng Liu, Jiahao Yang, Yifan Yang, Changsheng Li, Bo Han, and Mingkui Tan. Detecting adversarial data by probing multiple perturbations using expected perturbation score. In International conference on machine learning, pp. 41429–41451. PMLR, 2023.
Yaoyuan Zhang, Yu-an Tan, Mingfeng Lu, Tian Chen, Yuanzhang Li, and Quanxin Zhang. Boosting cross-task adversarial attack with random blur. International journal of intelligent systems, 37(10): 8139–8154, 2022.
A Notation
For ease of reference, we summarize in Table 4 the main symbols and spaces used throughout the paper. Unless otherwise noted, all notation is consistent across sections.
| Symbol | Meaning |
|---|---|
| Data & embeddings | |
| Dataset of images (dimension ). | |
| Label set and label of . | |
| CNN feature extractor. | |
| Embedding of . | |
| Prime quantization map with key and resolution . | |
| Prime-quantized embedding of . | |
| Prime-quantized space (Euclidean metric). | |
| Product spaces & metrics | |
| CNN-label product space; | |
| Prime-label product space (analogous metric). | |
| Neighborhoods & radii | |
| -nearest neighbors of in . | |
| Clean / adversarial -NN radii in . | |
| Distance of -th neighbor to in . | |
| Separation gap between outer and inner neighbor groups. | |
| GW quantities & envelopes | |
| Quadratic and entropic GW discrepancies. | |
| Distance matrix in space . | |
| Coupling (transport plan) in GW. | |
| GW upper / lower envelopes. | |
| Two-sided GW margin. | |
| Perturbations & constants | |
| Adversarial perturbation and budget. | |
| Median pairwise distance in . | |
| Key-annealed median; maximum over dataset. | |
| Variance proxy (Assumption A1). | |
| Prime gap bound (Dusart) and sensitivity constant. | |
| Confidence parameters (clean/env/grad/est/gap). | |
| Input dim, embedding dim, #classes, #samples, #neighbors. | |
| Secret key bits; quantization resolution. | |
Table 4: Notation summary used throughout the paper.
B Proofs for Prime Quantization Results
Proof Roadmap. The auxiliary results in this section establish the robustness of the prime quantization transform under bounded perturbations. We begin with Lemma 5, which shows how a perturbation of size translates into an integer drift in the scaled domain. This feeds directly into Theorem 4, which proves that whenever the perturbation budget exceeds the distance to a prime boundary, one can construct a feasible perturbation that crosses the gap, thereby changing the quantized value. To complement this, we define the absorption radius (Definition 7), derive the guarantee that perturbations below this radius are absorbed (Proposition 1), and bound the possible size of this radius in Lemma 1. Finally, Corollary 1 ties these ingredients together, yielding a crisp detection condition: perturbations below the absorption radius leave quantization unchanged, while those above it necessarily induce a detectable change.
Lemma 5 (Perturbation budget constraint on scaled pixel values). Let be an image and its -th pixel. Consider a perturbation vector with . Then for each pixel ,
Proof. We have and . Since , it follows that and hence . By the floor inequality , it follows that,
Theorem 4 (ε-Dependent Gap-Crossing Detection). Let be the j-th pixel of an image, with , and let be a perturbation budget such that
Then there exists a perturbation with such that and lie in different prime gap intervals, and hence
for any secret bit .
Proof. From Lemma 5, any perturbation induces an integer drift in the scaled domain of at most . Thus, whenever exceeds the distance from to the nearest prime boundary, some perturbation exists that pushes across that boundary.
Since , two cases arise:
(i) Closer to . If and , choose with . Then , placing the perturbed value in .
(ii) Closer to . If and , choose with . Then , placing the perturbed value in .
In both cases, and lie in different prime-gap intervals. Since rounds each integer to one of the two primes bracketing its interval, the images
must map to disjoint prime sets. Hence
Therefore, if , some perturbation necessarily changes the prime quantization output, regardless of the secret bit .
Remark 1. The condition in Theorem 4 is sufficient: it ensures that some perturbation of size crosses a prime boundary, though not every direction must. This simplification is enough for our later GW separation results.
Definition 7 (Absorption radius). For with , the absorption radius is .
Proposition 1 (Absorption guarantee). If , then for all bits .
Proof. By Definition 7 of absorption radius , we have for the same prime gap interval. Since both and lie in the same prime gap , the prime rounding operator maps both to the same prime: .
Applying to both sides:
Lemma 6 (Elementary Prime Gap Bound Hardy & Wright (1979)). For any two consecutive primes , we have the prime gap as .
Assumption 1 (Prime-gap envelope for all ). Let . There exists an absolute constant covering such that
satisfies for all consecutive primes . This is a direct consequence of Proposition 6.8 in Dusart Dusart (2010).
Lemma 1 (Absorption bounds). For any , .
Proof. By Definition 7, for the -th pixel with and consecutive primes satisfying , the absorption radius is
We will now proceed to prove each bound separately.
(i) Lower bound. Since is an integer, it follows that , and hence and . Therefore , which implies .
(ii) Upper bound. The maximum of occurs when is at the midpoint of the prime gap, i.e., . Since by construction, it follows that . Hence, we obtain , which completes the proof.
Corollary 1 (Absorption vs. Gap-Crossing Condition). Let be a pixel and a perturbation budget. Then:
(i) Absorption. If , every is absorbed, i.e. .
(i) Gap crossing. If , there exists some for which .
Proof. Part (i) is an immediate consequence of Proposition 1. For part (ii), Theorem 4 ensures that whenever , equivalently , one can construct a perturbation that shifts into a different prime-gap interval, thereby altering the prime quantization output.
Lemma 2 (Collision probability). Fix and let . Let be two independent random images with i.i.d. pixel marginals whose densities are bounded by on (in particular, for the uniform distribution). For a fixed secret bit vector , let be the prime-quantization transform (Definition 4). Assume the prime-gap envelope from Assumption 1. Then, . In particular, for , the collision probability decays as in the number of pixels.
Proof. Fix two independent images with i.i.d. pixel marginals of density at most on . Let , and for each pixel index define the scaled integers
Partition into prime-gap intervals with lengths . Since each pixel marginal has density , the probability of landing in any integer bin is . Therefore, for any gap ,
For a fixed secret bit , collision occurs at pixel if both and fall in the same gap , since then maps both to the same prime. By independence of and ,
Pixels are i.i.d. across i, so collisions at all d coordinates occur with probability
Finally, note that , where is the prime-gap envelope from Assumption 1. Hence, , yielding the stated bound.
Remark 2 (Numerics and scope). For ( ) with empirical maximum gap , the per-pixel factor is , so for CIFAR-10 ( ) the bound is at most . For ( , ), the per-pixel factor is and the overall bound is even smaller. This result is distributional, i.e., it certifies that collisions are exponentially unlikely for two independent draws with bounded pixel densities. It does not claim that is injective on (the map is many-to-one by construction). Rather, it quantifies that image-level collisions are negligible under natural sampling.
C Proofs for bounds in product metric spaces
Roadmap. In Section 5, we introduced the spatial–semantic product spaces C and K, both endowed with the metric. The purpose of this appendix is to justify that choice. We first establish in Theorem 5 that upper bounds in an product space always imply corresponding bounds in the component spaces. We then prove in Corollary 2 that among all metrics, achieves the tightest possible uniform upper bound. Together these results explain why is the natural metric for C and K, ensuring that perturbations in either spatial geometry or class distribution immediately translate into separation in the product space.
Let and be metric spaces. We consider their product space endowed with a standard product metric. For , this metric is defined by
and for by
We now establish a general theorem relating upper bounds in the product space W to upper bounds in the component spaces X and Y.
Theorem 5 (Component-wise Upper Bounds from Product Metrics). Let and be metric spaces, and let with the metric for some . Suppose there exists a constant such that
Then the following component-wise bounds hold:
Proof. We consider two cases:
(i) . By definition, for any ,
Since and , it immediately follows that
Taking the -th root on both sides gives . An identical argument applies to .
(ii) . By definition,
Hence, by properties of the maximum function,
Combining the two cases, the theorem follows.
Corollary 2 (Tightest Upper Bound in Product Spaces). Let and have known upper bounds and respectively, i.e.,
Then the corresponding upper bound for the product space is
Moreover, among all product metrics, the metric achieves the tightest upper bound, i.e.,
and is therefore optimal when minimizing the guaranteed upper bound in the product space.
Proof. The bound for follows directly from the monotonicity of the norm:
For , by definition . To see that is the tightest, observe that for any , . Equality occurs only if one of or is zero. Hence, gives the smallest guaranteed upper bound over all norms.
Definition 8 (Spatial, semantic, and product metric spaces). Let be the image space and the label set. For a representation map , define the spatial metric space with and . The semantic metric space is with and .
Their product is the metric space
Each image embeds as where is its class label. Projections are defined by and . Instantiating yields the space with spatial component , and instantiating yields with spatial component .
Instantiating or yields the product spaces and , respectively. These will serve as the foundation for the GW bounds in Section 5.
D Proofs for Diameter Bounds in C and K
Proposition 2 (Concentration in product spaces). Let be metric spaces and let be endowed with the product metric . Let be a random element of and fix reference points (e.g., means or Fréchet means), writing .
Assume that each coordinate concentrates around its reference point, i.e., there exist tail functions such that for all ,
Then the product random element concentrates around m in : for all ,
Proof. The event equals , which is contained in the union . Apply the union bound and the assumed coordinate-wise tail bounds.
Corollary 3. (1) For and real-valued coordinates with , letting and gives
Theorem 6 (CNN Product Space Clean Diameter Bound). Let be the CNN product space (with the product metric; cf. Proposition 2), and let denote the spatial feature dimension of . Fix a clean query and let denote its -nearest neighbors among i.i.d. clean samples. Then for any and any , under a standard -NN sampling regime, with probability at least ,
where is the clean median pairwise distance in C.
Proof. We first establish that distances between clean embeddings in the product space C satisfy sub-Gaussian concentration properties. This will serve as the foundation for bounding K-NN diameters. Recall the definition of a sub-Gaussian random variable. Throughout this section, the spatial metric is assumed to be normalized, ensuring concentration at scale .
Definition (Sub-Gaussian random variable). A real random variable is called sub-Gaussian with parameter if for all ,
Equivalently, its tail probabilities satisfy .
For a random vector , we say is sub-Gaussian if every linear functional is sub-Gaussian:
where for a random variable Y, the sub-Gaussian norm is .
Each image maps to the product space via , where is its CNN embedding and its class label. For two clean images , we denote their embeddings by and define the product space distance as .
We now analyze the spatial and semantic components of .
Spatial component. The embedding has sub-Gaussian coordinates due to several architectural and statistical effects. Namely, batch normalization enforces near unit variance and zero mean across feature activations Ioffe & Szegedy (2015); Santurkar et al. (2018). In Poole et al. (2016); Schoenholz et al. (2017), the authors demonstrate CLT effects arise from weighted sums of many independent activations, yielding approximately Gaussian tails. Moreover, Regularization techniques (e.g., weight decay Krogh & Hertz (1991), dropout Srivastava et al. (2014)) further constrain magnitudes, supporting sub-Gaussian tails Wager et al. (2013).
Formally, if is the empirical variance of a coordinate in Z, then for all ,
Thus is sub-Gaussian with , where . By standard results (see (Vershynin, 2018, Thm. 3.1.1)), Euclidean distances between embeddings in concentrate sharply around their mean.
Semantic component. The label projection contributes
which is bounded in and deterministic once class labels are fixed.
Product space concentration. Recall that
Applying Proposition 2 with n = 2 shows that concentration of the spatial distance transfers to the product metric, up to the bounded semantic coordinate. Accordingly, we summarize the resulting clean pairwise-distance behavior via the tail proxy
which we use in the remainder of the proof.
K-NN order statistics to diameter bound. Fix a clean query z and let denote the distance between z and the i.i.d. clean samples . Let denote the order statistics. For any threshold , the classical characterization of order statistics (David & Nagaraja, 2004, Eq. 2.1.3) gives
The event on the right means that there are at least indices for which . Equivalently, there exists a subset with such that
That is,
Applying the union bound to equation 11 yields
Since the s are i.i.d., the probability for any fixed S factors as
There are such subsets S. Hence equation 12 simplifies to
We now shift our focus to the next part, where we bound the diameter via pairwise bounds on the -nearest neighbor set. Let be the nearest neighbors of (ties broken arbitrarily), and write . By the triangle inequality, for any ,
Taking the maximum over yields the deterministic bound
Fix with . By equation 13 and the single-distance tail equation 9,
To obtain a high-probability bound, we select such that the preceding upper bound is at most a prescribed failure probability . Taking logarithms of the bound
this requirement is satisfied whenever
We work in a standard K-NN sampling regime in which the candidate pool is sufficiently large compared to (for example, ), so that . Absorbing absolute constants (including and the term) into , it suffices to choose
which yields
Combining this bound with equation 14 gives, with probability at least ,
This completes the proof.
Corollary 4 (95% confidence bound). For confidence level , the K-nearest neighbor diameter in C satisfies, under the assumptions of Theorem 6,
with probability at least 95%. In particular, the excess diameter above the clean median scale decays as .
Notation. We adopt the metric space setup of Definition 8. In particular, denotes the CNN product space and the prime-quantized product space. Let and denote the clean median pairwise distances in and respectively. We consider adversarial perturbations with , where is the fixed attack budget.
Definition 9 (Adversarial query). Let be a clean input with ground-truth label . For an -bounded perturbation , the adversarial query under a representation map is
where denotes the feature space associated with . Thus, adversarial queries live in the same feature–label product space as clean points. Note that a classifier may produce a prediction , but is not part of the definition. Instantiating gives and hence adversarial queries in the CNN product space , while instantiating gives and hence adversarial queries in the prime-quantized product space .
Assumption 2 (A1: variance-only control via Jacobian proxy). Let be the feature displacement under perturbation . For small perturbations with , we assume there exists a constant (a variance proxy) such that
Interpretation. By first-order Taylor expansion, , where is the Jacobian of at (with the feature dimension). Thus,
Assumption equation 15 requires that each row has second moment bounded by , so that the expected squared shift across features grows at most linearly with (via ) and quadratically with .
By Chebyshev's inequality, for any ,
Here acts as a tolerance parameter: it specifies the probability mass we are willing to allocate to rare large deviations in feature shifts. Smaller values of yield higher-probability guarantees but make the bound looser. This provides a high-probability control of adversarial feature shifts using only variance information, without assuming Lipschitz continuity or sub-Gaussianity of the Jacobian.
Remark 3 (Relating and budgets). An budget implies an budget , and conversely an budget implies budget . This allows translating -based results to our setting and vice versa.
In the adversarial setting, the k-NN neighborhood can enlarge primarily through displacement of the query relative to its clean location. Thus, bounding the query’s displacement (via Assumption 2) allows us to extend the clean k-NN diameter bound to the adversarial case.
Theorem 7 (Adversarial K-NN diameter bound in ). Fix and confidence levels . Let be a clean query with label , and let be an adversarially perturbed query with . Let and let denote the adversarial query (with the classifier prediction).
Assume: (i) Theorem 6 (clean K-NN diameter concentration); (ii) Assumption 2 (variance-controlled feature displacement); (iii) the K-NN gap condition
where denotes the r-th nearest-neighbor distance from z (ties excluded).
Then, with probability at least ,
Proof. By Theorem 6, for any fixed clean query , we have
with probability at least over the i.i.d. clean sample.
Assumption 2 bounds the feature shift . Since is an product metric, a label change contributes at most , and therefore
For any dataset point , the triangle inequality implies , so all query–dataset distances are perturbed by at most . Let denote the dataset, and let denote the same points reordered so that , with .
Under the gap condition equation 17, we now show that the K-nearest-neighbor set is stable under the perturbation from z to q. For any dataset point u, the triangle inequality implies
Let denote the dataset points ordered by increasing distance from the clean query , so that . In particular,
Subtracting these two inequalities yields
By the gap condition equation 17, the right-hand side is strictly positive, which implies . Since for all , the above inequality implies that no index can enter the K-NN set under the perturbation. Consequently, the identity of the K nearest neighbors is preserved when the query moves from z to q, and therefore .
Let . For any , the triangle inequality yields
Taking maxima over gives . Intersecting the clean diameter event and the displacement event and applying a union bound yields probability at least . On this event, we arrive at the claimed bound.
Assumption 3 (Prime-gap sensitivity under bit flips). Fix and let be the prime-gap envelope from Assumption 1. Then, for every coordinate , every two images , and any two secret keys that differ only at bit , we have
Explanation. Flipping one bit can move the j-th coordinate by at most one local prime gap . For two inputs, both coordinates may shift, so by the triangle inequality their pairwise difference changes by at most , regardless of the absolute difference.
Definition 10 (Key-annealed (data-quenched) median in ). Fix a clean query and a fixed clean image (or, more generally, a fixed dataset and query). Let denote the environment, where and is either fixed or drawn independently from a prescribed distribution . Define
The key-annealed (data-quenched) median for the pair is
When a single symbol is used, we write for with the convention that the probability is over only (the data are held fixed).
For brevity, we denote the maximal key-annealed median by
Theorem 8 (Annealed-over-keys clean K-NN diameter in K). Assume the prime-gap envelope (Assumption 1). Let the key and let the granularity be either fixed or drawn independently from a prescribed distribution . Fix a clean query and a fixed dataset (data quenched). Define
Then for any integer and any , with probability at least over the draw of ,
where .
Proof. Fix the clean dataset and the clean query ; these are held deterministic in this theorem. We first condition on an arbitrary realization of . All probabilistic statements below are with respect to and . Since all bounds depend on only through and hence uniformly through , the resulting bounds hold uniformly in and therefore also with respect to the joint draw . Assume moreover that (a standard regime where is polynomial in ). For notational simplicity, we continue to write for .
Fix any pair of dataset indices. For simplicity of notation, let . Define the spatial distance under key as
Now flip a single key bit while keeping all other bits fixed. By Assumption 3, the -th coordinate difference can change by at most (a single prime-gap shift per image, hence a change for a difference), while all other coordinates remain unchanged:
From a vector viewpoint, let
where is the m-th standard basis vector. Then the Euclidean norm changes by at most
Therefore, is coordinate-wise -Lipschitz in each bit .
Let be uniformly random with independent bits. By McDiarmid's inequality,
Write the product embedding as . Define the product distance
Since the label indicator is deterministic, . Thus,
Applying a union bound over all dataset pairs yields
Fix and choose . Then equation 25 implies equation 26 with this .
If we additionally work in a regime where , the same satisfies after absorbing absolute constants.
With this choice, we obtain the uniform bound
Since , the maximum over neighbor pairs is bounded by the maximum over all dataset pairs; hence .
By definition, . Therefore,
where .
Let be the embedded query and let be its nearest neighbors. We now impose the following scale condition (data quenched): there exists an absolute constant such that . Under this condition, .
Substituting and simplifying yields, with probability at least ,
This completes the proof.
Corollary 5 (Quenched-in-key clean diameter bound). Under the assumptions of Theorem 8, there exists a set of keys with such that for every (and the given ), the bound in Theorem 8 holds for the fixed key and the given clean dataset and query :
Proof sketch. The set is the (key, )-event on which the union bound in equation 26 holds; this event has probability . On , the derivation of Theorem 8 is deterministic, hence the bound is valid for every (quenched).
Theorem 9 (Adversarial K-NN diameter in (concise reuse)). Fix and . Let be the clean query and the adversarial query (predicted label may differ from ). Assume the prime-gap sensitivity bound (Assumption 3) at granularity , and define .
Assume moreover the same data-quenched scale condition as in Theorem 8: there exists an absolute constant such that
where and . The K-nearest-neighbor set is stable under the perturbation, i.e., . Finally, assume the variance-only adversarial displacement control (Assumption 2), i.e., with probability at least , . Then, with probability at least over the draw of the key b (and k, if random),
Proof. The proof follows that of Theorem 8 verbatim for the clean case (with clean query x and fixed dataset ). In particular, the McDiarmid concentration for pairwise distances under random keys, the union bound over dataset pairs, and the resulting high-probability envelope equation 26 are unchanged. The only modification is that the K-NN set is now formed with respect to the adversarial query (instead of the clean query x), and we relate the resulting pairwise distances to the clean anchor via a triangle inequality.
Let
where is the classifier prediction on . Let denote the nearest neighbors of in . For any pair among these neighbors, the triangle inequality gives
The first two terms are controlled exactly as in the clean proof (applied with the clean anchor ), yielding the term together with the key-fluctuation term . For the adversarial displacement term, by the product metric,
By Assumption 2 and Chebyshev's inequality, with probability at least ,
Combining these bounds, and intersecting the clean-key event (probability ) with the displacement event (probability ), yields the stated inequality.
E A Brief Primer on Metric Measure Spaces and Gromov–Wasserstein Distances
E.1 Metric Measure Spaces
A metric measure space (mm-space) is a triple , where is a Polish space, is a metric on , and is a Borel probability measure on . Intuitively, an mm-space encodes both the geometry (via ) and the distribution of mass (via ).
Two mm-spaces and are considered equivalent if there exists a measure-preserving isometry , i.e. and . This quotienting ensures that we compare spaces only up to relabeling of points.
The classical notion of distance between mm-spaces is the Gromov–Hausdorff distance, which measures how well two spaces can be embedded into a common metric space with small distortion. However, it is highly combinatorial and not well-suited to data applications.
E.2 The Gromov–Wasserstein Distance
The Gromov–Wasserstein (GW) distance relaxes Gromov–Hausdorff by using optimal transport ideas. For two mm-spaces and , the squared GW distance is defined as
where is the set of couplings with marginals . Thus GW finds a soft correspondence between X and Y and penalizes discrepancies between their intra-space distances.
Properties
• GW is a metric on the space of mm-spaces up to equivalence.
• If and , then GW = 0 regardless of labeling.
• GW generalizes Wasserstein distance: if X = Y as sets with the same underlying metric, then GW reduces to .
Statistical viewpoint. For empirical datasets , , the metric structure is given by pairwise distance matrices and . The GW distance then becomes a quadratic assignment problem over couplings with row/column marginals , .
E.3 Entropic Gromov–Wasserstein Distance
The GW optimization in equation 28 is computationally hard due to its quadratic objective. To address this, Peyré et al. (2016) introduced the entropic regularized GW distance, defined as
where is the Shannon entropy and is the regularization parameter.
Effects of entropic regularization.
• Computational: The problem becomes smooth and solvable by Sinkhorn-like iterations, scaling to tens of thousands of points.
• Statistical: inherits concentration bounds and enjoys faster empirical convergence (regularization reduces variance).
• Geometric: The optimal coupling becomes diffuse, capturing probabilistic alignments between X and Y.
Connections to our work. In our setting, the product spaces (CNN) and (Crypto) each define mm-spaces under their product metrics and empirical measures. Our clean vs. adversarial concentration bounds on k-NN diameters directly control the intra-space geometry terms in equation 28. Thus, these results serve as building blocks for bounding clean/adversarial GW and entropic GW distances, providing rigorous separation guarantees for detection.
Abuse of notation. Throughout the paper, we use , , and interchangeably when the underlying metric spaces and probability measures are clear from context. In particular, denotes the Gromov–Wasserstein distance between the metric measure spaces induced by X and Y equipped with their respective metrics and empirical measures.
F Proofs for Gromov–Wasserstein bounds
Definition 11 (Quadratic Gromov–Wasserstein discrepancy). Let and be metric–measure spaces. A coupling is a probability measure on whose marginals are and , i.e.
The quadratic GW discrepancy is defined as
Remark 4 (Upper bound by identity coupling). For brevity, we write as the quadratic GW discrepancy between two metric-measure spaces and . Let and , with distance matrices and . Consider the identity coupling . Since is an infimum over couplings, evaluating at any feasible gives an upper bound:
More generally, for any permutation (with permutation matrix ), the coupling yields
These bounds are typically loose but serve as alignment-dependent certificates.
Theorem 1 (Clean cross-space GW upper bound via K-NN radii). Fix a clean query x and consider its local neighborhoods and , each endowed with the uniform probability measure on K points.
Let and denote the clean K-NN radii in and , respectively. Assume the clean radius envelopes and hold with probabilities at least and , as established in Appendix D.
Then, with probability at least , the quadratic Gromov–Wasserstein discrepancy between the clean neighborhoods satisfies
Proof. Let and be the neighbors in and , respectively, both with the uniform measure . We denote their distance matrices as and , which satisfy . By Remark 4, evaluating the quadratic GW objective at the identity coupling yields
Let be the clean query center in and the center in . Define the -NN radii as and . By the triangle inequality in each product metric, we have
Hence every off-diagonal entry of (resp. ) is bounded by (resp. ).
There are exactly off-diagonal entries. Using equation 31 we arrive at
Therefore, by the triangle inequality for ,
(32)
Substituting equation 32 into equation 30 yields
On the event we have , and therefore . Finally, by the union bound, , which concludes the proof.
Notation (adversarial queries, radii, and separation gap). Let be a clean image and a perturbation. For each space , define the adversarial query as , the embedding of the perturbed image into . As the dataset is fixed and only the query moves, so the -NN neighborhood may change membership relative to the clean case. We define the adversarial neighborhood as , which are the nearest neighbors to under . The associated adversarial radii are , and .
Adversarial shifts often produce a “cluster split” in these radii, i.e., some neighbors become unusually close to , while others remain farther away. To capture this structure, we partition into an inner group and an outer group of sizes and by thresholding . The adversarial separation gap in is
which is positive when the inner and outer sets are well separated.
Theorem 2 (Adversarial cross-space GW lower bound). Fix a query x and perturbation , and consider the adversarial neighborhoods and , each with uniform measure on K points. Let be the separation gap and let denote the adversarial K-NN diameter in , bounded as in Appendix Theorem 9. Define the adversarial -diameter . Then, with probability at least ,
Proof. In any metric space (M, d) with center q, one has for all u, v,
We apply this to the adversarial neighborhoods. For the -space, each has radii , while for the -space, each has radii .
Hence,
We now identify which neighbor pairs give us a guaranteed discrepancy. Recall that the adversarial neighborhood in is partitioned into an inner set of size and an outer set of size , with separation gap .
A natural question arises, namely, Why focus on cross pairs? If both indices come from (outer–outer) or both from (inner–inner), the corresponding radii may be very close, and no nontrivial separation is guaranteed. However, whenever one index and the other , we know .
By the triangle inequality bound equation 33,
Therefore, for any cross pair or , and for all choices of in ,
How many such pairs exist? Define . Then
Thus, exactly ordered pairs enjoy the guaranteed discrepancy equation 34, which will next drive our GW lower bound.
For any coupling with uniform marginals, the GW objective can be written as
Fix any ordered cross pair . By equation 34, for every pair in we have , where we used that holds uniformly for all . Squaring both sides yields
Since the coupling has uniform marginals, the total weight assigned to the block after summing over is fixed:
Therefore for each , . Summing over all gives
because contributions from pairs outside are nonnegative and can be dropped. Finally, recalling , we arrive at . As this bound is independent of the choice of coupling, it continues to hold after taking the infimum over . Finally, substituting the high-probability envelope for from Appendix Theorem 9 yields the explicit form of the bound, which completes the proof.
Remark 5 (Instantiating from clean geometry). The abstract separation parameter in Theorem 2 can be linked to earlier results. Let and be the clean and adversarial queries, with the clean -NN neighborhood partitioned into inner set and outer set . The clean separation gap is
By our earlier adversarial absorption radius analysis in C, adversarial perturbations shift each star distance by at most . Hence the induced adversarial gap satisfies
Thus is not an arbitrary constant: it can be certified from clean geometry plus the perturbation shift and possible label flip.
Corollary 6 (Explicit clean–adversarial gap across C and K). Combining Theorem 2 with Remark 5, with probability at least ,
This bound separates the clean structure, the C-side adversarial shift, and the K-side absorption, making the cross-space adversarial gap explicit.
F.1 Mirror theorems for upper and lower bounds on GW
Theorem 10 (Clean cross-space GW lower bound). Fix a clean query x and its clean neighborhoods and , each with uniform measure on K points. Suppose the clean C-radii around the clean center exhibit a separation gap
for a partition into inner L and outer H of sizes and . Let denote the clean K-NN radius in K, bounded by the clean K envelope. Then
Proof sketch. Identical to Theorem 2 (Steps 1–4) with “adversarial” replaced by “clean” and replaced by . The cross-pairs enforce an entrywise gap of at least ; uniform marginals then yield the factor after averaging over couplings.
Theorem 11 (Adversarial cross-space GW upper bound via K-NN star radii). Fix a query x and perturbation , and consider the adversarial neighborhoods
each with uniform measure on K points. Let and denote the adversarial K-NN radii in C and K, respectively (each bounded by the adversarial envelopes in those spaces). Then
Proof sketch. Copy Theorem 1 verbatim, replacing clean radii by adversarial radii. The identity coupling and Frobenius argument give . Each off-diagonal entry is at most by triangle inequality via the adversarial centers, so , which yields the claim.
F.2 Gap theorem in GW
We now combine the clean and adversarial envelopes established in Theorems 1, 2, 10, and 11 to show that their GW discrepancies are separated by a margin that is nonvanishing in high dimension.
Theorem 3 (Cross-space GW gap). With probability at least , the clean and adversarial GW discrepancies satisfy , where and . Under Assumption 2, for fixed K and perturbation , we obtain .
Proof. On the joint event where all four bounds hold:
which implies
Similarly,
which implies
Taking the maximum of these two margins yields the result.
Discussion. Clean side. For fixed K, as , the clean K-NN radii in C concentrate according to Theorem 6, yielding
so the excess clean radius above the median scale contracts at rate . On the side, the clean envelope from Theorem 8 includes key-induced fluctuations scaling as (up to factors), and therefore need not vanish with dimension under the present assumptions. Accordingly, the clean cross-space GW upper bound remains uniformly controlled but does not rely on contraction of radii.
Adversarial side. A perturbation shifts the K-NN star distances in by
which induces a separation gap between inner and outer neighbors. Meanwhile, absorption in is controlled by the adversarial envelope , as established in Theorem 9. Let denote the lower bound in Theorem 2. Substituting the bounds on from Remark 5 and on from Theorem 9 yields
Gap scaling. Combining the clean upper envelope with the adversarial lower envelope, we obtain a margin of the form
where the second term reflects the clean -side geometry. In particular, even though does not contract with , the adversarial contribution grows linearly in dimension, so the gap is asymptotically nonvanishing whenever . Thus, robustness in high dimension is achieved through separation growth on the side rather than contraction on the side.
Implication for entropic solvers. Because the GW gap remains bounded away from zero in this regime, entropic relaxations that preserve relative ordering inherit the same discriminative power, justifying our detector design.
F.3 Entropic GW Corollaries and Risk Control
Corollary 7 (Entropic relaxation preserves lower bounds). For any metric–measure spaces and and any ,
Hence the lower bounds of Theorems 2 and 10 remain valid verbatim under entropic GW.
Corollary 8 (Entropic slack in upper bounds). For uniform marginals on K points,
Thus the upper bounds of Theorems 1 and 11 hold with additive slack .
Corollary 9 (Quenched key version). All high-probability envelopes on the K-side radii (Theorems 8, 2, 11) were stated in the annealed sense, averaging over random keys . By conditioning, the same inequalities hold for any fixed with identical probability bounds over the randomness of image sampling and adversarial perturbations.
Risk control The GW gap theorem (Theorem 3) ensures that, with high probability, the clean and adversarial discrepancies and are separated by a margin . In practice, however, we only observe the empirical, regularized estimator , which deviates from the truth due to (i) statistical sampling noise and (ii) entropic bias. If these deviations exceed , the detector may fail. The next lemma formalizes that controlling the estimation error to suffices.
Lemma 4 (Risk control via GW margin). If the gap event holds with margin and an estimator satisfies , then thresholding at the midpoint between clean and adversarial envelopes makes no error on this event. Thus .
Proof. On the event , the clean and adversarial discrepancies satisfy conditions and , with , and symmetrically and , with . By definition, , so there exists a threshold lying strictly between the clean and adversarial ranges, with a buffer of at least to each side.
In the case of a clean instance, on we have that . Since , we conclude , so the classifier correctly outputs “clean.”
For an adversarial instance, on , we have . Since , we similarly conclude , so the classifier correctly outputs “adversarial.”
Thus, on , the plug-in classifier is error-free. Finally, since holds with probability at least (from Theorem 3) and with probability at least , a union bound yields .
Discussion. Lemma 4 formalizes the transition from a theoretical gap to a practical detector. Theorem 3 ensures a margin exists between clean and adversarial discrepancies. The lemma shows that if the empirical entropic GW estimator concentrates within of the truth, then a midpoint threshold separates the two classes with zero error. The factor 1/3 is convenient: it splits the error budget evenly, allowing statistical variance and entropic bias to each consume at most . This provides a direct analogue to margin-based classifiers in statistical learning: once the theoretical gap is positive, robust classification depends only on estimator concentration, not on further geometric properties of C or K. In particular, higher dimension amplifies , so the limiting risk is controlled primarily by solver accuracy and sample complexity rather than geometry itself.
G Details of Adversarial Image Generation
We focus on the following white-box and black-box attacks in this work across the supervised and zero-shot settings:
G.1 White-Box Attacks
White-box attacks assume access to the internal parameters of the target model.
• Auto Attack (Croce & Hein, 2020): A parameter-free ensemble attack combining four complementary attacks: APGD-CE, APGD-DLR, FAB-T, and Square Attack. The ensemble automatically selects optimal hyperparameters and provides reliable robustness evaluation without manual tuning.
• Carlini & Wagner (C&W) Attack Carlini & Wagner (2017): An optimization-based attack that formulates adversarial example generation as:
where with representing logits, the target class, and the confidence parameter.
• Projected Gradient Descent (PGD) Attack Madry et al. (2018): An iterative first-order adversarial attack using projected gradient descent:
where denotes projection onto the constraint set and is the loss function.
• Auto-PGD (APGD) Attack (Croce & Hein, 2020): An enhanced version of PGD with automatic step size adaptation and momentum. The step size is dynamically adjusted based on the loss trajectory:
where counts the number of step size reductions and .
• Fast Gradient Sign Method (FGSM) (Goodfellow et al., 2014): A single-step attack that generates adversarial examples using:
where J is the cost function used to train the neural network, are the model parameters, and controls the perturbation magnitude.
• Universal Adversarial Perturbation (Moosavi-Dezfooli et al., 2017): Generates image-agnostic perturbations that fool classifiers across different inputs:
where v is the universal perturbation, is the data distribution, and is the desired fooling rate.
• Adversarial Patch Attack Brown et al. (2017): Generates printable adversarial patches that can cause misclassification in the physical world:
where applies patch p to image x at location l with transformation t, and is the target class.
G.2 Black-Box Attacks
Black-box attacks operate without knowledge of internal model parameters.
• Frequency Attack Yin et al. (2019): Exploits the vulnerability of neural networks in the frequency domain by applying perturbations to the Fourier transform:
where denotes the Fourier transform and represents frequency-domain perturbations.
• Square Attack Andriushchenko et al. (2020): A query-efficient score-based black-box attack that uses random search within balls:
where is a random direction sampled uniformly from and is the step size adapted based on the attack success.
• Gaussian Blur Attack (Zhang et al., 2022): Applies Gaussian blur to exploit the frequency bias of deep neural networks:
where controls the blur intensity and the convolution generates the adversarial example.
• Semantic Rotation Attack (Hosseini & Poovendran, 2018): Applies geometric transformations including rotations that preserve semantic content while causing misclassification:
where represents the rotation angle applied to the input image coordinates.
• Pixel Flip Attack (Su et al., 2019): A sparse attack that modifies only a few pixels to cause misclassification:
where is the set of modified pixel locations, represents the pixel modifications, and denotes the modification operation.
G.3 Adversarial Image Generation in the Supervised Setting
In the supervised setting, adversarial examples are generated against traditional classification models trained on labeled datasets. The model produces logits through a standard forward pass:
where denotes the neural network with parameters , is the input image, and are the raw logits for classes.
The final classification layer is typically a linear transformation:
where is the penultimate layer representation, is the weight matrix, and is the bias vector.
The predicted class probabilities are obtained via the softmax function:
where is the logit for class c.
During adversarial attack generation, the commonly used loss function is the cross-entropy loss:
G.4 Adversarial Image Generation in the Zero-Shot Setting
In the zero-shot setting, adversarial examples are generated against Vision-Language Models (VLMs) using its image encoder model (in our case CLIP Radford et al. (2021)), which do not require training on the target classes. The model consists of separate image and text encoders that project inputs into a shared embedding space.
Given an input image and a set of class names , the zero-shot classification process proceeds as follows:
Image Encoding: The image encoder maps the input image to an -normalized embedding in the shared representation space:
where represents the normalized image embedding with unit norm.
Text Encoding: For each class , a text prompt is constructed using the template “A photo of ”. The text encoder maps each prompt to a normalized embedding in the same shared space:
where denotes the vocabulary space and is the normalized text embedding for class .
Logit Computation: The logits are computed as the temperature-scaled cosine similarities between the image embedding and each text embedding:
where is a temperature parameter that controls the sharpness of the similarity distribution. The complete logit vector is:
Classification Decision: The predicted class is obtained by selecting the class with the maximum logit value:
The class posterior probabilities are obtained through softmax normalization:
G.5 Adversarial Attack Hyperparameter Selection
In this section, we provide the detailed configuration of adversarial attack methods used in our experiments (Section 6). Table 5 summarizes the set of hyperparameters chosen for each attack. These values are selected following common practice in the adversarial robustness literature to ensure a fair comparison across methods.
We consider a diverse set of attack strategies, including optimization-based, gradient-based, score-based, and patch-based approaches. For gradient-based methods such as PGD, Auto-PGD, FGSM, and Square Attack, we evaluate under multiple perturbation budgets with . Universal Perturbation is evaluated with a wider range of perturbation strengths, namely .
For optimization-based attacks, the Carlini & Wagner (CW) attack is configured with confidence parameter , following the default setting to generate minimally perturbed adversarial examples. AutoAttack is evaluated under , consistent with its standardized benchmark protocol.
Patch-based and spatial transformations are included to account for more physically realizable adversarial scenarios. The Patch Attack is tested with square patches of shape and , while the Spatial Attack allows for up to rotation and translations of up to 10% of the image dimensions.
In addition to the attacks described above, we also include several specialized perturbations and image corruptions to probe robustness across different perturbation modalities: a Frequency Attack with noise strength noise_strength = 0.05, Gaussian Blur with (blur_type set to “uniform”), Pixel Flip with num_pixel = 5 and attack mode set to “random”, and a Semantic Rotation with angle = . These parameter choices are summarized in Table 5 and were chosen to reflect common settings used in prior work while providing a broad coverage of perturbation types.
These configurations ensure that the evaluation captures a broad spectrum of attack types, ranging from small-norm pixel perturbations to structured and geometric transformations. See Table 5 for an overview of the attack methods and the full set of parameter values used in our experiments.
| Attack Method | Parameter Values |
|---|---|
| AutoAttack (AA) | ε = 4/225, 8/225 |
| C&W (CW) | κ = 0.0 |
| Patch Attack (PT) | patch_shape = (3, 8, 8), (3, 16, 16) |
| PGD | ε = 4/255, 8/255 |
| Spatial Attack (SA) | max rotation: 30°, max translation: 10% of the image size |
| Square Attack (SQ) | ε = 4/255, 8/255 |
| Universal Perturbation (UP) | ε = 4/255, 8/255, 12/255 |
| Auto-PGD (AP) | ε = 4/255, 8/255 |
| FGSM (FG) | ε = 4/255, 8/255 |
| Frequency Attack (FA) | noise_strength = 0.05 |
| Gaussian Blur (GB) | σ = 1.0, blur_type = uniform |
| Pixel Flip (PF) | num_pixel = 5, attack_mode = random |
| Semantic Rotation (SR) | angle = 8 |
Table 5: Overview of adversarial attack methods and their parameter settings. Parameter value written with bold represents the default value of the corresponding attack among its parameter configurations.
G.6 Examples of Adversarial Images Supervised Setting
G.6.1 Gaussian Blur Attack
Original image label: car

Perturbed image Predicted label: truck

Perturbation

Figure 3: Comparison between Original and Perturbed Images using Gaussian blur attack. Left: Original Image with True Label car, Center: Adversarial Image with Predicted Label truck and Right: Perturbation
Original image
label: plane

Perturbed image
Predicted label: bird

Perturbation

Figure 4: Comparison between Original and Perturbed Images using Gaussian blur attack. Left: Original Image with True Label plane, Center: Adversarial Image with Predicted Label bird and Right: Perturbation
G.6.2 Patch Attack
Original image
label: car

Perturbed image
Predicted label: truck

Perturbation

Figure 5: Comparison between Original and Perturbed Images using Patch attack. Left: Original Image with True Label car, Center: Adversarial Image with Predicted Label truck and Right: Perturbation
Original image
label: plane

Perturbed image
Predicted label: bird

Perturbation

Figure 6: Comparison between Original and Perturbed Images using Patch attack. Left: Original Image with True Label plane, Center: Adversarial Image with Predicted Label bird and Right: Perturbation
G.7 Examples of Adversarial Images Zero Shot Setting
G.7.1 APGD Attack
True
Dolphin

Predicted Camera

Perturbation

Figure 7: Comparison between Original and Perturbed Images using APGD attack. Left: Original Image with True Label Dolphin, Center: Adversarial Image with Predicted Label Camera and Right: Perturbation
G.7.2 PGD Attack
True
Trilobite

Predicted
Helicopter

Perturbation

Figure 8: Comparison between Original and Perturbed Images using APGD attack. Left: Original Image with True Label Trilobite, Center: Adversarial Image with Predicted Label Helicopter and Right: Perturbation
H Detection Methods Configuration
This section provides detailed descriptions of the adversarial detection methods evaluated in our experiments, with configurations specified in Table 6. Further, we also mention the hyperparameter settings used in our defense approach.
H.1 Mahalanobis Detector
The Mahalanobis detector (Lee et al., 2018) leverages the Mahalanobis distance to measure distributional deviations of test samples from training data in the neural network’s feature space. For a given sample x and its feature representation at layer , the method computes class-conditional Gaussian distributions from clean training data. The Mahalanobis distance is defined as:
The minimum distance across all classes serves as the confidence score for adversarial detection, exploiting the property that adversarial perturbations typically push samples away from the natural data manifold.
H.2 Feature Squeezing
Feature Squeezing (Xu et al., 2018) reduces the degrees of freedom available to adversarial perturbations by applying input transformations that compress the feature space. Our implementation uses median smoothing with a kernel and distance metric for comparing predictions. For an input and its squeezed version , the detection score is computed as:
where represents the model's prediction probabilities. A threshold is determined using the training false positive rate (FPR) of 0.2, assuming legitimate inputs remain robust to minor spatial transformations while adversarial examples exhibit significant prediction changes.
H.3 MetaDetect
MetaDetect (Ma et al., 2019) formulates adversarial detection as a few-shot learning problem using meta-learning principles. The method employs episodic training with support sets and query sets , where indicates clean (0) or adversarial (1) samples. Our configuration uses support example and query examples with a conv3 architecture. The meta-detector learns a function that maps from support-query episode pairs to detection decisions, optimizing over episode distributions to generalize across different attack types.
H.4 MagNet
MagNet (Meng & Chen, 2017) combines detection and defense mechanisms using autoencoder-based reconstruction and probability estimation. The method trains an autoencoder on clean data to approximate the natural data manifold. For detection, it computes the reconstruction error:
Additionally, MagNet estimates the probability density using the Jensen-Shannon divergence between the original and reconstructed inputs' predicted distributions. The underlying assumption is that adversarial examples, lying off the natural manifold, will exhibit higher reconstruction errors and lower probability estimates compared to legitimate inputs.
| Detection Method | Parameters |
|---|---|
| Mahalanobis Detector | train_fpr = 0.15 |
| Feature Squeezing | distance metric: , squeezer: median smoothing (), train_fpr=0.2 |
| MetaDetect | num_support = 1, num_query = 15, arch = conv3 |
| MagNet | norm reconstruction error, train_fpr = 0.15 |
Table 6: Parameters and configurations for different adversarial detection methods. Methods referenced: Mahalanobis (Lee et al., 2018), Feature Squeezing (Xu et al., 2018), MetaDetect (Ma et al., 2019), and MagNet (Meng & Chen, 2017).
H.5 Hyper Parameter Configuration for the Proposed Method
| Hyperparameter | Candidate Values | Optimal Value | Description |
|---|---|---|---|
| 8 | Local Gromov-Wasserstein features | ||
| 3 | Global Gromov-Wasserstein features | ||
| 0.5 | Entropic regularization strength |
Table 7: Hyperparameter search for GW features: We performed a grid search over the candidate values of each hyperparameter and chose the values that achieved the best trade-off between robustness and model usability. Based on this search, we selected the optimal parameters as , , and .
| Hyperparameter | Candidate Values | Optimal Value | Description |
| Kernel | {linear, rbf, poly} | rbf | Choice of kernel function |
| {0.1, 1, 10, 100} | 1 | Regularization parameter | |
| {scale, auto, 0.01, 0.001} | scale | Kernel Coeff. for RBF |
Table 8: Hyperparameter search for SVM: We performed a grid search over the candidate values of each hyperparameter and selected the optimal configuration based on validation accuracy. The chosen parameters are Kernel = rbf, , scale.
I Adaptive Attack Formulation
Evaluating the robustness of a defense mechanism against an adaptive adversary is crucial. We consider an adversary who possesses complete knowledge of the defense’s architecture, including the classifier , the CNN feature extractor , and the crypto feature extractor with its associated transform . However, the adversary is unaware of the defender’s specific, fixed secret bit vector used in deployment. This section formalizes the adversary’s objective and optimization strategy to generate adversarial examples under this realistic uncertainty, focusing on two distinct consistency-based attacks. This approach is typical for evaluating defenses against strong, adaptive attackers Athalye et al. (2018).
I.1 Attacker's Prior over Secret Bits
To account for the unknown secret , the adversary models it as a random variable drawn from a prior distribution . This prior is constructed as a mixture model over a set of plausible Bernoulli distributions, , reflecting the adversary's uncertainty about the specific statistical properties of :
where corresponds to the individual Bernoulli success probability for each distribution type in (e.g., for uniform or Gaussian-threshold components, and specific probabilities like 0.3, 0.7 for biased Bernoulli components). This mixture prior allows the adversary to account for various possibilities of how the defender might have generated . Modeling unknown parameters in this manner is a standard robust optimization technique Ben-Tal et al. (2009).
I.2 Attacker's Objective Function
The adversary's goal is to craft an adversarial example from a benign input that achieves misclassification by while simultaneously maintaining a high degree of feature consistency with . The latter ensures the adversarial example does not trip the defense's detection mechanisms, particularly those relying on the crypto features. Since the specific is unknown, the adversary targets an average consistency, minimizing the expected penalty under their prior .
The general adversarial objective is:
where is the cross-entropy loss for the true label , which the adversary seeks to maximize; is a weighting factor that balances the misclassification objective against the consistency penalty — a formulation commonly used in adversarial attacks to trade off attack success and imperceptibility or stealth Carlini & Wagner (2017); quantifies the discrepancy between features of and for a given , with lower values of implying better stealth against consistency checks; and defines the allowed perturbation space, typically restricted to a range for pixel values.
I.3 Consistency Penalties
We define the consistency penalty using an OT-like discrepancy metric, . This metric compares feature vectors distance if dimensions match) or their statistical summaries
distance between mean, std, min, max, skewness, kurtosis if dimensions differ or comparison of statistics is explicitly requested).
For this study, we consider two specific attack formulations based on distinct consistency penalties:
I. 3.1 Cross-Space Consistency Attack ( )
This attack targets the defense by imposing consistency across both the standard CNN feature space and the specialized crypto feature space. The adversary aims to ensure that the features extracted from the adversarial example x remain similar to those from the clean input in both domains. The penalty term is defined as the sum of discrepancies in each feature space:
By minimizing this penalty, the adversarial example is constrained to modify the input in a way that, on average over , preserves the inherent characteristics captured by both and .
I. 3.2 Multi-Scale Consistency Attack ( )
This attack extends the cross-space consistency by introducing an additional constraint on global CNN feature similarity. This reflects a defense that might perform multi-scale or global consistency checks specifically on CNN features. The penalty is structured as:
where:
-
represents the local, cross-space consistency across CNN and crypto features.
-
ensures global consistency focusing solely on CNN features. Note that does not depend on b, as the global consistency check is assumed to be deterministic based on CNN features, which are not secrets-dependent.
The combined penalty
effectively doubles the weight on CNN feature consistency, making the adversarial example potentially harder to detect by defenses performing aggregated checks on CNN features.
To optimize the objective function, the adversary utilizes an iterative PGD Madry et al. (2018) is used. Since the objective involves an expectation over the unknown b, a Monte Carlo (MC) approximation is employed Rubinstein & Kroese (2016).
J Implementation Details
J.1 Pseudocode for Cross-Space Detector
Algorithm 1 Multi-Scale Cross-Space GW Detector
Require: Image ; ;
1 for all do
2 Build , ; compute , , ,
3 ;
4 ;
5 end for
6 return SVM( ) {clean, adv}
We provide the hyperparameter selection details for GW features in Table 7 and for SVM classifier in Table 8.
K Additional Experiments
K.1 Additional Baseline Defences and Attacks
To evaluate performance against imperceptible and optimization-free attacks, we extend our experiments to three recent low-magnitude adversarial methods, i.e., AdvAD, PGN, and BSR, which explicitly target the small-perturbation regime. These attacks probe the limits of pixel-level stability and serve as stringent tests for detectors relying on fine-grained geometric discrepancies.
In addition to our default ResNet-18 backbone, we generate all attacks using a Vision Transformer (ViT) to assess robustness across fundamentally different architectural families. Table 9 reports binary detection accuracy for all attacks and defenses. Table 10 reports corresponding AUROC values.
Across all attack types—including classical gradient-based attacks (PGD, SQ, PT) and modern diffusion-based or non-parametric attacks (AdvAD, PGN, BSR)—our detector achieves the strongest performance on both ResNet-18 and ViT. Competing baselines degrade substantially under stronger or low-magnitude attacks, whereas our Z–P discrepancy remains highly separable across architectures, perturbation magnitudes, and attack mechanisms.
| Attack | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 97.8 | 91.7 | 74.4 | 46.3 | 81.9 | 97.5 | 69.5 |
| ViT | 95.7 | 49.8 | 70.3 | 57.5 | 49.4 | 93.2 | 77.5 | |
| SQ | ResNet-18 | 97.6 | 89.1 | 88.5 | 45.8 | 91.9 | 91.9 | 59.5 |
| ViT | 96.2 | 51.0 | 87.3 | 56.3 | 49.7 | 90.5 | 62.5 | |
| PT | ResNet-18 | 98.0 | 86.4 | 67.3 | 46.5 | 50.1 | 90.1 | 78.0 |
| ViT | 95.4 | 51.3 | 71.2 | 54.9 | 49.3 | 89.5 | 78.5 | |
| AAD | ResNet-18 | 96.4 | 54.4 | 41.3 | 49.6 | 53.2 | 94.6 | 61.0 |
| ViT | 93.7 | 52.6 | 52.7 | 53.6 | 50.1 | 92.7 | 80.0 | |
| PGN | ResNet-18 | 96.5 | 70.8 | 61.0 | 45.6 | 49.6 | 94.9 | 75.0 |
| ViT | 96.9 | 52.2 | 65.8 | 53.7 | 49.9 | 94.9 | 75.5 | |
| BSR | ResNet-18 | 95.0 | 73.0 | 42.4 | 45.5 | 62.1 | 92.9 | 78.5 |
| ViT | 98.7 | 51.9 | 53.9 | 53.7 | 50.0 | 93.2 | 76.0 |
Table 9: Detection accuracy (%) on CIFAR-10 for a range of classical and low-magnitude attacks, evaluated using ResNet-18 and ViT. Best results are in bold; second best are underlined.
| Attack | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 0.99 | 0.81 | 0.69 | 0.49 | 0.51 | 0.99 | 0.72 |
| ViT | 0.99 | 0.72 | 0.72 | 0.57 | 0.49 | 0.96 | 0.89 | |
| SQ | ResNet-18 | 0.99 | 0.55 | 0.87 | 0.48 | 0.49 | 0.95 | 0.54 |
| ViT | 0.99 | 0.40 | 0.88 | 0.56 | 0.50 | 0.95 | 0.60 | |
| PT | ResNet-18 | 0.99 | 0.93 | 0.52 | 0.50 | 0.54 | 0.95 | 0.89 |
| ViT | 0.99 | 0.47 | 0.63 | 0.54 | 0.52 | 0.94 | 0.90 | |
| AAD | ResNet-18 | 0.99 | 0.61 | 0.56 | 0.49 | 0.51 | 0.97 | 0.55 |
| ViT | 0.98 | 0.88 | 0.55 | 0.53 | 0.53 | 0.97 | 0.94 | |
| PGN | ResNet-18 | 0.99 | 0.79 | 0.59 | 0.48 | 0.50 | 0.98 | 0.80 |
| ViT | 0.97 | 0.54 | 0.61 | 0.55 | 0.51 | 0.98 | 0.81 | |
| BSR | ResNet-18 | 0.99 | 0.64 | 0.53 | 0.48 | 0.51 | 0.95 | 0.87 |
| ViT | 0.99 | 0.59 | 0.58 | 0.55 | 0.54 | 0.96 | 0.84 |
Table 10: AUROC comparison on CIFAR-10 for various attacks generated using ResNet-18 and ViT. Best results are in bold; second best are underlined.
K.2 Experimental evaluations with additional metrics
| Attacks | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 0.97/0.98 | 0.89/0.95 | 0.71/0.72 | 0.17/0.54 | 0.97/0.65 | 0.98/0.95 | 0.67/0.74 |
| ViT | 1.00/0.90 | 0.49/0.95 | 0.73/0.78 | 0.57/0.57 | 0.25/0.01 | 0.98/0.93 | 0.72/0.90 | |
| SQ | ResNet-18 | 0.96/0.97 | 0.88/0.89 | 0.83/0.88 | 0.16/0.52 | 0.22/0.01 | 0.89/0.92 | 0.60/0.54 |
| ViT | 0.95/0.94 | 0.50/0.98 | 0.93/0.80 | 0.56/0.57 | 0.40/0.01 | 0.88/0.90 | 0.63/0.60 | |
| PT | ResNet-18 | 0.97/0.98 | 0.87/0.84 | 0.62/0.49 | 0.17/0.57 | 0.55/0.01 | 0.91/0.88 | 0.72/0.91 |
| ViT | 0.99/0.93 | 0.50/0.98 | 0.75/0.61 | 0.53/0.56 | 0.25/0.01 | 0.89/0.87 | 0.72/0.92 | |
| AAD | ResNet-18 | 0.98/0.93 | 0.63/0.21 | 0.55/0.41 | 0.49/0.54 | 0.87/0.07 | 0.89/0.93 | 0.61/0.57 |
| ViT | 0.93/0.92 | 0.51/1.00 | 0.55/0.61 | 0.82/0.53 | 0.41/0.01 | 0.89/0.95 | 0.73/0.95 | |
| PGN | ResNet-18 | 0.97/0.93 | 0.83/0.51 | 0.67/0.59 | 0.15/0.51 | 0.34/0.01 | 0.90/0.91 | 0.70/0.85 |
| ViT | 0.98/0.95 | 0.51/0.99 | 0.67/0.58 | 0.82/0.53 | 0.44/0.01 | 0.92/0.94 | 0.71/0.86 | |
| BSR | ResNet-18 | 0.99/0.91 | 0.84/0.55 | 0.45/0.62 | 0.15/0.51 | 0.94/0.25 | 0.96/0.88 | 0.72/0.92 |
| ViT | 0.99/0.98 | 0.50/0.98 | 0.51/0.64 | 0.82/0.53 | 0.42/0.01 | 0.93/0.91 | 0.71/0.87 |
Table 11: Precision / Recall comparison of adversarial detection on CIFAR-10 under various attacks generated using ResNet-18 and ViT, with best results in bold and second best underlined.
Table 11 reports the precision and recall of different adversarial detection methods across six attack types using both ResNet-18 and ViT. Across nearly all attacks and architectures, our method achieves the highest precision and recall values (highlighted in bold), often reaching near-perfect scores close to 1.00, demonstrating its strong ability to accurately detect adversarial inputs. In contrast, EA generally appears as the second-best performer, but still lags behind our approach, particularly on challenging attacks such as AAD, PGN, and BSR. Overall, these results show that our detector is highly robust and consistent, maintaining superior numerical performance across all attack families and both model architectures.

Figure 9: PR curves for our method on attacks generated via ResNet-18 model on CIFAR10 dataset. The small inset box displays a zoomed-in view of the upper-right corner of the PR curves.
In Figure 9, the Precision–Recall (PR) curves show that our detector maintains consistently high precision and recall across all six attack types. All curves remain close to the top-right region, indicating strong overall detection performance. The zoomed inset further illustrates that even at high recall values (close to 1.0), the precision for each attack remains above 0.95 with only minimal degradation. The high Average Precision (AP) scores (0.987 – -0.998) confirm the robustness of our method, demonstrating reliable performance even against stronger modern attacks such as AdvAD, PGN, and BSR. Overall, the PR curves highlight that our approach is highly accurate, stable, and generalizes well across diverse adversarial attacks.
Table 12 shows that our method consistently achieves the highest end-to-end detection accuracy across all evaluated attacks. For every attack type, our detector outperforms all competing defenses, often by margins of 10–40%. FS and MD occasionally achieve the second-best performance, but
| Ours | MD | FS | MAD | MN | |
|---|---|---|---|---|---|
| AA | 94.9 | 67.2 | 82.0 | 48.3 | 71.6 |
| CW | 93.8 | 72.1 | 85.3 | 48.9 | 54.2 |
| PT | 94.4 | 84.9 | 67.1 | 49.5 | 54.8 |
| PGD | 94.8 | 90.0 | 73.7 | 49.0 | 78.5 |
| SA | 93.4 | 76.7 | 73.7 | 39.2 | 52.5 |
| SQ | 93.4 | 87.7 | 87.8 | 48.5 | 41.9 |
| UP | 94.4 | 65.0 | 52.9 | 49.0 | 45.4 |
| AP | 93.8 | 66.9 | 80.7 | 48.6 | 71.1 |
| FG | 94.3 | 72.3 | 60.2 | 49.1 | 42.2 |
| FA | 94.6 | 48.5 | 49.3 | 48.7 | 47.3 |
| GB | 73.2 | 48.5 | 50.9 | 48.1 | 46.1 |
| PF | 93.3 | 50.3 | 50.7 | 48.5 | 46.9 |
| SR | 93.1 | 48.9 | 52.0 | 48.9 | 46.8 |
Table 12: End-to-end accuracy (%). Best results are in bold and second best are underlined.
| Attacks | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 95.6 | 50.00 | 68.9 | 45.8 | 91.00 | 94.9 | - |
| SQ | ResNet-18 | 96.7 | 50.00 | 84.2 | 45.5 | 49.00 | 89.6 | - |
| PT | ResNet-18 | 96.2 | 50.00 | 73.7 | 45.0 | 50.50 | 88.2 | - |
| AAD | ResNet-18 | 97.6 | 50.00 | 55.9 | 49.6 | 59.38 | 95.4 | - |
| PGN | ResNet-18 | 96.3 | 50.00 | 63.2 | 46.3 | 49.06 | 93.2 | - |
| BSR | ResNet-18 | 97.8 | 50.00 | 59.4 | 46.35 | 50.31 | 93.6 | - |
Table 13: Detection accuracy (%) comparison on ImageNet + ResNet-18 with best (bold) and second best (underlined).
they remain substantially weaker overall, while MAD and MN lag far behind on most attacks. These results demonstrate that our approach generalizes robustly across a broad spectrum of adversarial perturbations and maintains reliable detection performance even against diverse and challenging attack strategies.
K.3 Evaluation on the ImageNet Dataset on default ResNet-18 model
In this section, we additionally evaluate our method on the large-scale ImageNet Deng et al. (2009) dataset using the default ResNet-18 backbone. This allows us to verify that the detector remains effective when applied to high-resolution images and a significantly more challenging data distribution.
Note: The BY He et al. (2024) baseline does not provide a publicly available codebase, so we reproduce the method following the details reported in the original paper. Running BY requires a self-supervised model trained on the target dataset; while we trained such a model for CIFAR-10, training an equivalent backbone for ImageNet is computationally prohibitive. Consequently, we omit BY from the ImageNet experiments due to the intractable training cost and scale of the dataset.
Tables 13, 14, and 15 jointly show that our detector achieves the strongest overall performance on ImageNet across all six adversarial attacks. In terms of detection accuracy and AUC, our method consistently reaches top performance—typically in the 0.98–0.99 range—while the next-best baseline, EA, trails by 1 – 5% depending on the attack. The precision and recall results further reinforce this trend: our detector attains the best or second-best PR scores in nearly all settings, maintaining high recall even for challenging attacks such as AdvAD, PGN, and BSR. Competing defenses such as MD, FS, MAD, and MN perform substantially worse across all metrics. Together, these results confirm that our approach scales robustly to high-resolution ImageNet data and preserves strong discriminative ability under a wide range of adversarial perturbations.
| Attacks | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 0.98 | 0.53 | 0.73 | 0.503 | 0.68 | 0.98 | - |
| SQ | ResNet-18 | 0.97 | 0.55 | 0.79 | 0.489 | 0.49 | 0.94 | - |
| PT | ResNet-18 | 0.99 | 0.52 | 0.71 | 0.45 | 0.50 | 0.95 | - |
| AAD | ResNet-18 | 0.99 | 0.49 | 0.55 | 0.495 | 0.45 | 0.96 | - |
| PGN | ResNet-18 | 0.98 | 0.50 | 0.66 | 0.488 | 0.44 | 0.95 | - |
| BSR | ResNet-18 | 0.99 | 0.50 | 0.62 | 0.488 | 0.43 | 0.95 | - |
Table 14: AUC comparison on ImageNet with best (bold) and second best (underlined).
| Attacks | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 1/0.93 | 0.50/1.00 | 0.65/0.82 | 0.05/0.55 | 0.92/1.00 | 0.98/0.97 | - |
| SQ | ResNet-18 | 0.98/0.96 | 0.50/1.00 | 0.84/0.76 | 0.05/0.52 | 0.42/0.06 | 0.89/0.91 | - |
| PT | ResNet-18 | 0.96/0.95 | 0.50/1.00 | 0.82/0.65 | 0.04/0.45 | 0.52/0.09 | 0.87/0.89 | - |
| AAD | ResNet-18 | 0.99/0.96 | 0.50/1.00 | 0.51/0.55 | 0.49/0.54 | 0.87/0.21 | 0.93/0.96 | - |
| PGN | ResNet-18 | 0.94/0.97 | 0.50/1.00 | 0.61/0.68 | 0.16/0.52 | 0.28/0.01 | 0.95/0.92 | - |
| BSR | ResNet-18 | 0.97/0.96 | 0.50/1.00 | 0.50/0.73 | 0.16/0.52 | 0.54/0.03 | 0.96/0.91 | - |
Table 15: Precision / Recall comparison on ImageNet under various attacks, with best values in bold and second best underlined.
| Attacks | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 0.96 | 0.66 | 0.72 | 0.10 | 0.96 | 0.97 | - |
| SQ | ResNet-18 | 0.96 | 0.66 | 0.79 | 0.09 | 0.10 | 0.90 | - |
| PT | ResNet-18 | 0.95 | 0.66 | 0.72 | 0.08 | 0.15 | 0.88 | - |
| AAD | ResNet-18 | 0.97 | 0.66 | 0.52 | 0.51 | 0.35 | 0.95 | - |
| PGN | ResNet-18 | 0.95 | 0.66 | 0.64 | 0.24 | 0.02 | 0.93 | - |
| BSR | ResNet-18 | 0.96 | 0.66 | 0.59 | 0.24 | 0.07 | 0.93 | - |
Table 16: F1 score comparison on ImageNet under various adversarial attacks. Best results are shown in bold, second best underlined.
K.4 Sensitivity to the Prime-Resolution Parameter

Figure 10: Sensitivity of the detector to the prime-resolution parameter .
Figure 10 shows how detection accuracy varies as the prime-resolution parameter is changed. Across the entire tested range ( to ), the mean detection accuracy remains extremely stable, fluctuating only within a narrow interval of approximately 0.954–0.957. The shaded region captures variability across repeated runs and likewise remains tightly concentrated.
These results indicate that the detector is not sensitive to the specific choice of . Even when is varied over a relatively broad range, the performance remains effectively unchanged. This robustness reflects an intrinsic property of our method, i.e., once the prime gaps are sufficiently fine to induce stable absorption and injectivity behavior, further refinement provides little additional benefit. In practice, this means that does not require fine-tuning to achieve strong performance, simplifying deployment across different datasets and architectures.
K.5 Comparison with Alternative Quantization Schemes
To assess whether the advantages of our quantization scheme can be replicated by other non-uniform discretization strategies, we compare it against three alternatives: Fibonacci quantization, logarithmic quantization, and standard uniform quantization. All approaches are evaluated under the same experimental setup and across five random seeds (1, 3, 5, 21, 42). Table 17 reports detection accuracy for each seed, together with the mean and standard deviation.
Across all seeds, our method achieves the highest mean accuracy and the lowest variance, demonstrating both improved performance and greater stability compared to all alternative discretization schemes.
| Quantization | Seed | Mean ± Std | ||||
|---|---|---|---|---|---|---|
| 1 | 3 | 5 | 21 | 42 | ||
| Ours | 0.94 | 0.92 | 0.95 | 0.94 | 0.96 | 0.94 ± 0.01 |
| Fibonacci | 0.62 | 0.61 | 0.55 | 0.60 | 0.68 | 0.61 ± 0.04 |
| Logarithmic | 0.70 | 0.61 | 0.61 | 0.56 | 0.58 | 0.62 ± 0.05 |
| Uniform | 0.65 | 0.65 | 0.60 | 0.56 | 0.65 | 0.62 ± 0.03 |
Table 17: Detection accuracy of different quantization schemes across five random seeds. Values reported using a ResNet backbone and CIFAR-10 under mixed attacks (PGD, FGSM, APGD).
Notably, replacing our scheme with Fibonacci or logarithmic quantization does not yield comparable results, despite also introducing non-uniform discretization. Uniform quantization performs similarly poorly. These results suggest that the structural properties of our secret prime quantization strategy are essential for producing a reliable Z–P discrepancy signal, and that generic discretization methods do not replicate this behavior in practice.
K.6 Sensitivity Analysis of and
| Accuracy | |
|---|---|
| 8 | 97.90 |
| 10 | 86.15 |
| 12 | 92.57 |
| 15 | 93.24 |
| Accuracy | |
|---|---|
| 3 | 97.90 |
| 5 | 95.60 |
| 7 | 83.45 |
| 10 | 85.35 |
Table 18: Detection accuracy as a function of the local neighborhood size (left) and the global neighborhood size (right).
We evaluate the sensitivity of our detector to the neighborhood parameters and , which govern the local consistency scale and the global support for GW coupling, respectively.
For the local neighborhood size, we test . Accuracy remains consistently high across all settings, with the best performance (97.9%) obtained at . While performance dips for , it recovers for larger values (12 and 15), indicating that the method is broadly robust to the choice of local scale.
For the global neighborhood size, we test . Smaller global neighborhoods yield the best performance, with achieving . Larger values gradually degrade performance, suggesting that excessively large global supports may introduce noise or dilute the structural alignment captured during cross-space GW coupling.
Overall, the detector displays stable performance across a wide range of neighborhood sizes, with optimal performance achieved at smaller values. Based on this analysis, we adopt and for all main experiments.
K.7 Robustness Against Common Corruptions
To assess whether the detector responds specifically to adversarial perturbations, rather than generic input noise, we evaluate its behaviour under benign corruptions using the CIFAR-C benchmark Hendrycks & Dietterich (2019a). CIFAR-C includes a diverse set of naturally occurring degradation types, such as Gaussian, shot, and impulse noise; blur corruptions (defocus, frosted glass, motion, zoom); weather effects (snow, frost, fog); brightness and contrast shifts; elastic distortions; pixelation; and JPEG compression.
Table 19 reports results for the Gaussian noise corruption. The detector maintains high accuracy and AUROC, indicating that benign perturbations do not trigger the characteristic Z–P discrepancies associated with adversarial attacks. This supports our claim that the method does not misclassify natural corruptions as adversarial.
| Corruption Type | Detection Accuracy | AUROC | Precision / Recall / F1 |
|---|---|---|---|
| Gaussian Noise | 96.43% | 0.99 | 0.97 / 0.96 / 0.96 |
Table 19: Performance of our detector under Gaussian noise (CIFAR-C).
| Method | Runtime (s) | CPU (GB) | GPU (GB) |
|---|---|---|---|
| BY | 0.152 | 2.00 | 0.60 |
| EA | 0.115 | 11.80 | |
| MD | 0.141 | 0.68 | |
| FS | 0.17 | ||
| MAD | 0.105 | 3.30 | 0.00 |
| MN | 0.78 | ||
| Ours | 0.120 | 0.62 | 2.04 |
Table 20: Runtime and memory usage of different adversarial detection methods on CIFAR-10. Best values in bold, second-best underlined.
K.8 Runtime and Memory Efficiency
Table 20 compares inference-time and memory footprint across several recent adversarial detection baselines. Our detector achieves a competitive runtime of 0.12 seconds per sample while maintaining a moderate CPU and GPU memory footprint. Methods such as BY He et al. (2024) require substantially larger memory because they process multiple transformed copies of each input, resulting in expanded intermediate activations. In contrast, our detector relies on a single forward pass through a ResNet backbone, leading to a modest GPU footprint.
Lightweight approaches such as FS Xu et al. (2018) and MN Meng & Chen (2017) offer faster runtimes but exhibit either higher memory usage or weaker robustness. Overall, our method strikes an effective balance among runtime efficiency, memory consumption, and detection performance.
K.9 Robustness and Generalization Capabilities
K.9.1 Reliability Analysis
We study detector reliability across a range of perturbation levels using TPR/FPR heatmaps (Fig. 11). With dataset and backbone fixed, only adversarial conditions vary, revealing how consistently detectors identify adversarial inputs while avoiding false positives on clean samples.

(a) TPR Heatmap (higher is better).

(b) FPR Heatmap (lower is better).
Figure 11: Reliability via TPR/FPR heatmaps. X-axis: attack types with perturbation levels, Y-axis: defenses. Thresholds are calibrated only on clean samples, so baselines yield constant FPR across attacks.
K.9.2 Cross-Attack Generalization
To evaluate generalization to unseen attacks, we train on ResNet18 adversarial samples from FG and PGD, then test on CW, SQ, SA, and PT. Results (Table 21) report accuracy, adversarial recall, and adversarial precision. Our method consistently outperforms baselines, demonstrating robustness to unseen attack families.
| Attack | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| CW | 97.5/100/95 | 71/51/86 | 90/90/90 | 49.5/69/46.6 | 60/45/63 |
| SQ | 93.5/98/89 | 88/85/91 | 94.5/99/90.8 | 48.5/63/47 | 45/15/46 |
| SP | 95.5/99/92 | 86/80/90 | 92.5/95/90.5 | 49/67/49 | 48/21/46 |
| PT | 95/100/90 | 91/90/91 | 89.5/89/89.9 | 49/67/49 | 45/15/37 |
Table 21: Cross-Attack Generalization. Accuracy / Recall / Precision (%).
K.9.3 Cross-Model Generalization
We also test transfer robustness by training on ResNet18 attacks and evaluating on FourierNet (FNet) adversarial samples. Table 22 reports detection accuracy, recall, and precision. Our method again outperforms baselines, showing resilience to model transfer attacks.
| Attack | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| CW | 95/97/94 | 54/17/68 | 73.5/91/67.4 | 50/69/50 | 50/25/52 |
| SQ | 87/93/83 | 51/10/55 | 77.0/98/69.0 | 49/67/49 | 52/29/54 |
| SP | 94/93/95 | 64/37/82 | 74/92/67.6 | 49/67/49 | 53/31/56 |
| PT | 96/95/97 | 57/22/73 | 72.5/89/66.9 | 47/64/48 | 49/22/47 |
| FG | 93/99/89 | 55/18/69 | 70.0/84/65.6 | 46/61/47 | 50/25/50 |
| PGD | 98/99/99 | 56/21/72 | 74.5/93/67.9 | 50/69/50 | 50/26/52 |
Table 22: Cross-Model Generalization. Accuracy / Recall / Precision (%).
K.10 True Positive Rate (TPR) Analysis
Table 23 reports the true positive rate (TPR) across adversarial attack types, i.e., the fraction of adversarial inputs correctly detected as adversarial. The formula is, . Bold entries denote the best-performing method, and underlined entries denote the second best. Our method consistently achieves the highest TPR in 12 out of 13 attacks, showing large margins especially for transfer-based (UP) and perceptual/frequency attacks (FA, PF, SR). The only exception is Gaussian blur (GB), where all detectors struggle, but our method still provides a clear advantage over baselines. These results highlight that our cross-space framework is particularly effective in reliably flagging adversarial samples, even under challenging attack families.
| Attack / Method | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| AA | 97.40 ± 1.07 | 50.60 ± 1.99 | 86.50 ± 1.24 | 57.96 ± 3.10 | 74.09 ± 1.26 |
| CW | 96.33 ± 0.57 | 59.90 ± 0.65 | 93.20 ± 0.14 | 56.82 ± 1.52 | 39.30 ± 1.60 |
| PT | 97.73 ± 0.34 | 85.50 ± 0.85 | 56.70 ± 2.49 | 55.33 ± 3.92 | 40.50 ± 1.66 |
| PGD | 97.20 ± 1.07 | 95.30 ± 0.62 | 69.90 ± 2.68 | 56.22 ± 1.18 | 87.90 ± 0.29 |
| SA | 96.67 ± 0.23 | 69.00 ± 1.91 | 69.90 ± 0.17 | 36.20 ± 0.62 | 35.80 ± 2.86 |
| SQ | 96.67 ± 0.90 | 91.20 ± 0.77 | 98.20 ± 1.12 | 55.90 ± 3.34 | 14.80 ± 1.12 |
| UP | 97.00 ± 1.14 | 45.60 ± 3.06 | 28.50 ± 2.52 | 55.80 ± 2.12 | 21.70 ± 1.17 |
| AP | 96.22 ± 1.11 | 49.30 ± 1.65 | 83.90 ± 1.44 | 54.28 ± 1.59 | 73.10 ± 1.51 |
| FG | 96.87 ± 1.57 | 60.30 ± 2.64 | 42.90 ± 3.26 | 53.09 ± 0.72 | 15.30 ± 1.57 |
| FA | 94.33 ± 1.23 | 12.50 ± 0.88 | 21.10 ± 1.23 | 53.34 ± 3.08 | 25.50 ± 1.78 |
| GB | 73.00 ± 10.27 | 12.40 ± 1.92 | 24.50 ± 0.53 | 50.42 ± 2.38 | 23.10 ± 2.06 |
| PF | 96.33 ± 0.57 | 16.10 ± 1.20 | 24.00 ± 0.46 | 53.01 ± 3.65 | 24.70 ± 1.21 |
| SR | 95.33 ± 1.07 | 13.30 ± 0.19 | 26.60 ± 1.24 | 54.20 ± 2.37 | 24.40 ± 2.29 |
Table 23: True positive rate (%) on adversarial samples: This table shows the results of TPR measured on adversarial samples.
| Attack | Ours | MD | MN |
|---|---|---|---|
| AA4 | 97.60 ± 0.22 | 50.00 ± 0.56 | 49.90 ± 1.59 |
| AA8 | 96.43 ± 0.59 | 50.40 ± 0.86 | 50.10 ± 1.75 |
| CW | 96.10 ± 1.63 | 51.60 ± 0.67 | 54.05 ± 1.43 |
| PT7 | 98.63 ± 0.17 | 89.45 ± 0.45 | 90.20 ± 0.32 |
| PT14 | 94.10 ± 0.49 | 90.20 ± 0.43 | 90.09 ± 0.32 |
| PGD | 97.63 ± 0.53 | 49.80 ± 0.67 | 49.90 ± 1.80 |
| PGD8 | 95.33 ± 0.97 | 51.45 ± 0.69 | 50.30 ± 1.82 |
| SA | 97.21 ± 1.36 | 80.80 ± 2.01 | 53.10 ± 0.15 |
| SQ | 97.20 ± 0.57 | 50.05 ± 0.55 | 50.00 ± 0.18 |
| SQ8 | 96.47 ± 4.01 | 52.20 ± 0.67 | 50.73 ± 0.52 |
| UP | 99.87 ± 0.05 | 50.05 ± 0.71 | 50.23 ± 1.85 |
| UP8 | 98.30 ± 1.27 | 51.15 ± 0.55 | 50.65 ± 1.50 |
| UP12 | 99.23 ± 0.68 | 54.75 ± 1.37 | 51.80 ± 1.23 |
| AP | 98.63 ± 0.34 | 49.70 ± 0.65 | 49.49 ± 1.74 |
| AP8 | 99.50 ± 0.36 | 50.05 ± 0.99 | 50.20 ± 1.83 |
| FG | 97.27 ± 3.44 | 59.95 ± 0.67 | 49.95 ± 1.66 |
| FG8 | 95.53 ± 0.62 | 51.85 ± 0.81 | 50.78 ± 1.73 |
| FA | 97.65 ± 0.78 | 68.90 ± 0.30 | 45.65 ± 0.90 |
| GB | 87.27 ± 0.32 | 68.12 ± 0.49 | 41.60 ± 0.10 |
| PF | 92.22 ± 0.45 | 69.68 ± 0.42 | 48.85 ± 1.17 |
| SR | 97.65 ± 0.76 | 70.30 ± 0.77 | 41.99 ± 1.43 |
Table 24: The results of binary accuracy on FMNIST using ResNet18.
| Attack | Ours | MD | MN |
|---|---|---|---|
| AA | 97.33 ± 0.33 | 50.10 ± 1.91 | 50.00 ± 1.00 |
| AA8 | 98.08 ± 0.26 | 50.30 ± 1.84 | 50.00 ± 0.98 |
| PT7 | 96.87 ± 0.35 | 53.35 ± 0.86 | 75.8 ± 0.72 |
| PT14 | 97.63 ± 0.46 | 52.20 ± 0.31 | 86.27 ± 0.27 |
| PGD | 98.10 ± 0.45 | 50.95 ± 1.72 | 49.45 ± 0.68 |
| PGD8 | 98.60 ± 0.36 | 51.80 ± 1.47 | 49.25 ± 0.69 |
| SA | 98.10 ± 1.85 | 50.45 ± 0.98 | 56.50 ± 0.39 |
| SQ | 98.77 ± 0.05 | 51.15 ± 1.49 | 48.85 ± 0.96 |
| SQ8 | 95.32 ± 3.51 | 52.25 ± 1.48 | 48.85 ± 0.85 |
| UP | 99.87 ± 0.05 | 51.15 ± 0.61 | 49.60 ± 0.67 |
| UP8 | 98.30 ± 1.27 | 52.05 ± 1.41 | 49.90 ± 0.10 |
| UP12 | 99.41 ± 0.05 | 53.10 ± 1.47 | 50.05 ± 0.70 |
| AP | 98.63 ± 0.34 | 50.60 ± 1.78 | 49.65 ± 0.68 |
| AP8 | 99.50 ± 0.36 | 51.35 ± 1.36 | 49.25 ± 0.69 |
| FG | 97.57 ± 1.54 | 51.15 ± 1.54 | 49.65 ± 0.68 |
| FG8 | 99.47 ± 0.25 | 52.05 ± 1.71 | 48.70 ± 0.10 |
| FA | 98.16 ± 1.76 | 50.00 ± 1.85 | 49.95 ± 0.91 |
| GB | 93.86 ± 0.34 | 38.85 ± 1.56 | 41.15 ± 1.04 |
| PF | 96.87 ± 0.65 | 49.00 ± 1.96 | 52.20 ± 0.74 |
| SR | 98.10 ± 1.85 | 48.95 ± 1.53 | 52.12 ± 0.66 |
Table 25: The results of binary accuracy on KMNIST using ResNet18.
K.11 Experiments on FMNIST and KMNIST
Table 24 and Table 25 show the result of the detection accuracy on FMNIST and KMNIST respectively. Regarding the performance of MD on FMNIST and KMNIST, we observed that the distributions of Mahalanobis scores for clean and adversarial samples did not show significant difference. This is because clean and adversarial features for FMNIST and KMNIST are fairly similar in the feature space of ResNet18, making it difficult for MD to distinguish between clean and adversarial samples. The similar feature representations in these datasets limit the separability of the two distributions of Mahalanobis scores. A similar phenomenon regarding the distributions of clean and adversarial features used for detection was observed in MN.
K.12 Zero-Shot Setting
Adversarial robustness in large-scale Vision-Language Models (VLMs) remains relatively under-explored, especially in the zero-shot regime where models are accessed only through APIs and adversaries rely on transfer attacks. This provides a natural testbed for evaluating cross-model generalization, since neither gradients nor model parameters are available.
We evaluate the zero-shot transferability of our detector across two recent VLMs—LLaVA-1.5-7B (Liu et al., 2023) and Qwen-2.7B-VL Yang et al. (2024)—on three diverse datasets: CalTech-101 Fei-Fei et al. (2004), Food-101 Bossard et al. (2014), and CalTech-256 Griffin et al. (2007).
| Attack | Dataset | Detection Accuracy / AUC | Precision / Recall / F1 | ||
|---|---|---|---|---|---|
| LLaVA-1.5 | Qwen-2.7B-VL | LLaVA-1.5 | Qwen-2.7B-VL | ||
| APGD | CalTech-101 | 89.50 / 0.99 | 89.63 / 0.99 | 0.89 / 0.89 / 0.89 | 0.89 / 0.89 / 0.89 |
| Food-101 | 90.44 / 0.99 | 87.72 / 0.99 | 0.90 / 0.90 / 0.90 | 0.87 / 0.87 / 0.87 | |
| CalTech-256 | 88.60 / 0.95 | 87.83 / 0.99 | 0.88 / 0.88 / 0.88 | 0.87 / 0.87 / 0.87 | |
| PGD | CalTech-101 | 89.50 / 0.99 | 87.13 / 0.99 | 0.89 / 0.89 / 0.89 | 0.87 / 0.87 / 0.86 |
| Food-101 | 87.13 / 0.99 | 88.42 / 0.99 | 0.87 / 0.87 / 0.87 | 0.88 / 0.88 / 0.88 | |
| CalTech-256 | 83.00 / 0.91 | 88.76 / 0.99 | 0.83 / 0.83 / 0.82 | 0.88 / 0.88 / 0.88 | |
| FGSM | CalTech-101 | 90.80 / 0.99 | 89.20 / 0.99 | 0.90 / 0.90 / 0.90 | 0.89 / 0.89 / 0.89 |
| Food-101 | 87.08 / 0.94 | 90.74 / 0.99 | 0.84 / 0.81 / 0.81 | 0.90 / 0.90 / 0.90 | |
| CalTech-256 | 85.50 / 0.92 | 88.07 / 0.99 | 0.85 / 0.85 / 0.85 | 0.88 / 0.88 / 0.88 | |
Table 26: Zero-shot adversarial detection performance on LLaVA-1.5 and Qwen-2.7B-VL across multiple datasets and attacks.
Adversarial examples are generated using PGD, APGD, and FGSM following (Cui et al., 2024), and CLIP (Radford et al., 2021) embeddings define the -space. Table 26 reports detection accuracy, AUROC, and precision/recall/F1 metrics for all model–dataset combinations.
Across all attacks and datasets, the detector achieves strong zero-shot transferability: detection accuracies are consistently , AUROC values (often ), and precision/recall/F1 scores typically remain . These results indicate robust generalization across VLM architectures without requiring access to model internals.
The robustness stems from adversarial perturbations disrupting semantic alignment in while being unevenly absorbed in , yielding a persistent cross-space discrepancy detectable even under transfer. Additional robustness and generalization results—including TPR/FPR heatmaps, cross-attack transfer, and cross-model generalization—are provided in Appendix K.
L Comparison of Our Proposed Defence Against Baseline Defences on CIFAR-10 Dataset
L.1 Binary Accuracy Comparison
In this section we present the binary accuracy results for detecting adversarial attacks on CIFAR-10. This metric measures how well each defense method can correctly classify samples as either adversarial or clean. Our proposed method consistently outperforms all baselines across all attack types, achieving accuracy rates between and . The Mahalanobis Detector (MD) shows the second-best performance for most attacks, while Feature Squeezing (FS) performs well on specific attack types like CW and PGD4. The MAD and MN methods show poor performance with accuracies around , essentially equivalent to random guessing. The standard deviations for our method are consistently low ( to ), indicating stable and reliable performance.
| Attack / Metric | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| AA8 | |||||
| CW | |||||
| PT8 | |||||
| PGD | |||||
| SQ | |||||
| UP | |||||
| AP8 | |||||
| FG8 |
Table 27: Comparison of detection performance (%) under different adversarial attacks: Bold values indicate the best performance, and underlined values denote the second-best.
| Attack / Metric | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| AA8 | 96.60 ± 0.86 | 93.56 ± 1.51 | 79.90 ± 1.72 | 55.67 ± 2.49 | 84.10 ± 1.03 |
| CW | 96.33 ± 0.57 | 59.90 ± 0.65 | 93.20 ± 0.14 | 56.82 ± 1.52 | 39.30 ± 1.60 |
| PT8 | 96.07 ± 0.5 | 18.40 ± 1.80 | 25.20 ± 0.39 | 40.83 ± 1.90 | 28.20 ± 1.03 |
| PGD | 97.07 ± 1.34 | 55.30 ± 1.12 | 83.40 ± 2.22 | 51.79 ± 1.78 | 78.10 ± 0.30 |
| SQ | 96.00 ± 0.75 | 86.50 ± 2.76 | 90.60 ± 1.48 | 52.19 ± 1.56 | 14.90 ± 1.23 |
| UP | 97.00 ± 1.14 | 45.60 ± 3.06 | 28.50 ± 2.52 | 55.80 ± 2.12 | 21.70 ± 1.17 |
| AP8 | 96.73 ± 1.09 | 92.60 ± 0.96 | 79.60 ± 3.50 | 55.69 ± 2.17 | 84.60 ± 2.73 |
| FG8 | 96.87 ± 0.96 | 84.50 ± 2.19 | 47.90 ± 3.63 | 55.32 ± 1.27 | 14.80 ± 1.49 |
Table 28: The results of TPR measured on 1k adversarial samples. TPR := (the number of adv correctly detected) / (the number of adv) × 100 (%). The best results are written in bold, and the second-best results are written with underlines.
L.2 TPR on Adversarial Samples Comparison
In this section we focus on True Positive Rate (TPR), which specifically measures how well each method detects adversarial samples (the percentage of adversarial samples correctly identified as adversarial). Our method maintains excellent TPR performance (96.00% to 97.07%) across all attack types. Feature Squeezing (FS) shows strong TPR for CW and SQ4 attacks (93.20% and 90.60% respectively) but performs poorly on P8 and UP4 attacks. The Mahalanobis Detector (MD) demonstrates good TPR for AA8 and AP8 attacks (92.3% and 91.4%) but fails significantly on P8 attack (16.8%). The MAD method shows moderate TPR (40.83% to 56.82%) but with high variance, while MagNet (MN) fails with low TPR for most attacks, indicating it cannot effectively detect adversarial samples.
L.3 End To End Accuracy Comparison
In this section we present the end-to-end accuracy, which is a comprehensive metric that considers both correct detection of adversarial samples by the detector and correct detection of clean samples and correct classification of clean samples. Our method achieves excellent end-to-end accuracy (93.9% to 94.8%) across all attack types, demonstrating consistent and robust performance. The Mahalanobis Detector (MD) shows moderate performance (51.0% to 89.0%) with good results on AA8 and AP8 attacks but struggling with P8 attack. Feature Squeezing (FS) shows reasonable performance (51.30% to 85.30%) but with significant variation across different attacks, performing well on CW and SQ4 attacks but struggling with P8 and UP4 attacks. The MAD method shows poor performance (42.03% to 49.18%) with accuracies around random guessing level. MagNet (MN) performs with low accuracies for most attacks, indicating it cannot provide effective end-to-end protection. The consistency of our method across different attack types demonstrates its robustness and reliability in maintaining both detection accuracy and classification performance under adversarial conditions.
| Attack / Metric | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| AA8 | 94.1 | 89.0 | 78.64 | 49.18 | 76.60 |
| CW | 94.8 | 72.0 | 85.30 | 48.92 | 54.20 |
| PT8 | 94.4 | 51.0 | 51.30 | 42.03 | 48.65 |
| PGD | 94.4 | 70.0 | 80.40 | 48.72 | 73.60 |
| SQ | 93.9 | 86.0 | 84.00 | 47.99 | 42.00 |
| UP | 94.4 | 65.0 | 52.94 | 48.99 | 45.40 |
| AP8 | 94.6 | 89.0 | 78.50 | 48.58 | 76.85 |
| FG8 | 94.5 | 84.0 | 62.64 | 49.04 | 41.95 |
Table 29: The results of end-to-end accuracy: ((the number of correctly detected adversarial samples by the detector)+(the number of correctly detected clean samples and correctly classified samples))/(1000 + 1000).
M Key Leakage Experiments
In this section, we measure the detection rate under a fully white-box adaptive attack where is known. Table 30 shows the detection rates. Detection degrades gradually as key knowledge increases, remaining at 65.31% at 75% recovery and reaching near-chance (55.17%) only under complete key compromise.
| Fraction of known | Detection rate (CIFAR-10) |
|---|---|
| 0% | 86.7% |
| 25% | 81.23% |
| 50% | 76.22% |
| 75% | 65.31% |
| 100% | 55.17% |
Table 30: Comparison of detection rates on CIFAR-10 as the fraction of known information varies from 0% to 100%.