Log-Depth Encrypted Shapley Values for Kernel Models

A client sends an encrypted patient record to a cloud model. Today the best it can get back is an encrypted prediction. It cannot also get an encrypted explanation of which of its features drove that prediction, because computing feature credit is combinatorially expensive, and doing it under encryption appeared even worse. We propose a way around this for one important model class. For kernel machines whose kernel is a product of per-feature factors, the exact Shapley values can be rewritten as a short integral of a product. A handful of quadrature points evaluates that integral exactly. The result is a circuit whose multiplication depth grows with the logarithm of the number of features rather than linearly. The server returns encrypted per-feature Shapley values, which are exact up to encryption rounding and cost only a small multiple of an encrypted prediction, without a second server and without extra client interaction.

Two terms need defining. Shapley values are the game-theoretic credit assignment that splits a prediction's deviation from a baseline among the input features. They are the unique split satisfying efficiency, symmetry, dummy and additivity (Explainable AI Methods - A Brief Overview). Homomorphic encryption lets a server add and multiply ciphertexts without decrypting them. Every multiplication consumes a "level" of noise budget, and exhausting the budget forces bootstrapping, the expensive refresh operation (Circuit Bootstrapping: Faster and Smaller). What we care about is therefore not operation count but multiplicative depth and numerical conditioning. The obvious port of the best plaintext exact algorithm does badly on both, and our reformulation does well on both.

Core Claim

Computing Exact Shapley Values in Polynomial Time for Product-Kernel Methods (PKeX-Shapley) shows that, for product kernels, the coalition sum collapses into elementary symmetric polynomials computed by Newton's identities. It reports processing 500 features in under 100 seconds with zero estimation error. That recursion is sequential, so its depth grows with the number of features $d$. It also alternates signs over large power sums, which invites cancellation in CKKS, an encryption scheme whose arithmetic is approximate.

We claim the same exact quantity has a representation with three properties. It is a product of affine terms, so it needs no alternating sums. It can be evaluated with $\lceil \log_2 d \rceil$ levels of ciphertext multiplication. It packs naturally into the parallel "slots" of a single ciphertext. This makes single-server, non-interactive encrypted local attribution practical for tabular kernel models at the feature counts that appear in the healthcare benchmarks in the file.

The Mechanism

Consider a product-kernel model $f(x)=\sum_{n=1}^{N}\alpha_n \prod_{j=1}^{d} a_{nj}$. Here $a_{nj}=k_j(x_j,z_{nj})$ is the per-feature kernel value between the client's feature $x_j$ and support vector $z_n$, and $\alpha_n$ are the server's plaintext coefficients. Under PKeX's functional baseline, an absent feature's factor is set to 1. More generally it can be set to a plaintext constant $b_{nj}$, for example a marginal kernel mean in the spirit of the interventional variant of RKHS-SHAP: Shapley Values for Kernel Methods under a product-of-marginals reference distribution.

The Shapley weights are Beta integrals, $\frac{s!(d-s-1)!}{d!}=\int_0^1 t^{s}(1-t)^{d-1-s}\,dt$. Substituting them into the coalition sum gives

$$ \phi_i=\sum_{n=1}^{N}\alpha_n\,(a_{ni}-b_{ni})\int_0^1 \prod_{j\neq i}\big((1-t)\,b_{nj}+t\,a_{nj}\big)\,dt . $$

The integrand is a polynomial of degree $d-1$ in $t$. Gauss–Legendre quadrature with $m=\lceil d/2\rceil$ nodes $t_q$ and weights $w_q$ is therefore exact:

$$ \phi_i=\sum_{n,q}\alpha_n\,w_q\,(a_{ni}-b_{ni})\,P^{(-i)}_{nq},\qquad P^{(-i)}_{nq}=\prod_{j\neq i}\big((1-t_q)b_{nj}+t_q a_{nj}\big). $$

This expresses the same exact quantity PKeX computes; only the evaluation order differs. The structure maps onto encryption cleanly. The affine mixing inside the product uses only ciphertext-times-plaintext operations. All $d$ leave-one-out products $P^{(-i)}$ come from a prefix/suffix product scan over slots, which costs $\lceil\log_2 d\rceil$ ciphertext multiplication levels plus rotations. Each factor lies in $[\min(b,a),\max(b,a)]$, so no cancellation occurs. The final weighted sum over $n$ and $q$ uses plaintext weights.

The prediction comes out of the same circuit: $f(x)$ is the $t=1$ full product. The only non-polynomial step is the per-feature kernel itself, for example $\exp(-(x_j-z_{nj})^2/2\ell^2)$. Inputs are normalized, so its argument lies in a known bounded interval. A Chebyshev approximation of degree $D$ then costs about $\log_2 D$ levels. This follows the range-restriction approach used in Converting Transformers to Polynomial Form for Secure Inference Over Homomorphic Encryption. The expected total depth is roughly $\log_2 D+\log_2 d+3$. For $d\le 64$ that should fit inside a standard CKKS parameter set without bootstrapping, a prediction the experiments test directly. Truncating the quadrature below $\lceil d/2\rceil$ nodes gives an explicit cost/accuracy knob with a computable error bound.

Research Program

We will build the protocol end to end on a CKKS library. The client encrypts a normalized record and replicates it across slots. The server evaluates the approximate kernel values against its plaintext support vectors, forms the affine mixtures at the quadrature nodes, runs the leave-one-out product scan, and reduces to encrypted $[\phi_1],\dots,[\phi_d]$ and $[f(x)]$. The slot layout is a design question in its own right. The product $N\cdot m\cdot d$ usually exceeds the slot count, so we will compare two tilings: packing across support vectors, and packing across quadrature nodes with support vectors streamed. For each tiling we measure rotation counts and key sizes, because key and ciphertext expansion is a documented cost of encrypted ML (A Systematic Comparison of Encrypted Machine Learning Solutions for Image Classification).

Analytically, we will derive the depth and CKKS error propagation of the scan and compare them with the Newton recursion, showing why bounded products are better conditioned than alternating power sums. We will also develop an optional training-time step that caps kernel lengthscales so the kernel's argument stays in a low-degree-friendly range. This mirrors range-minimization losses in polynomial Transformers.

The threat model is a single server that is honest but curious. The client learns $f(x)$ and $\phi$, exactly what a plaintext explanation API would reveal. We flag, but do not solve, the known risk that explanations aid model extraction.

The method's scope is limited to models whose value function is a sum of products of per-feature factors. That covers product-kernel SVMs, Gaussian-process regressors and kernel ridge regression with RBF or Laplacian kernels. It does not cover deep networks. The contribution is a model class that admits exact encrypted explanations, not a universal one.

Baselines

The naive reference point is encrypted prediction alone, running the same kernel model under the same CKKS parameters and returning only $[f(x)]$. The ratio of our latency to this latency is the headline "price of an explanation." We regard success as a ratio within a small constant factor, roughly under 5× at $d\approx 30$–$60$, rather than the thousands of evaluations sampling needs.

The strongest competitor is encrypted KernelSHAP, built as fairly as possible. The coalition sample and the weighted least-squares projection do not depend on the input. The server can therefore precompute the regression map in plaintext and apply it to an encrypted vector of coalition values $v(S)$, which are themselves products of $a_{nj}$ or $b_{nj}$ packed into slots. This removes the encrypted matrix inversion a naive reading suggests and makes KernelSHAP genuinely viable under encryption. We will give it the same CKKS parameters, the same kernel approximation, the same hardware and the same wall-clock budget, and sweep its coalition count. The file contains no reported result on Lacuna for KernelSHAP under homomorphic encryption. The plaintext reference point is that KernelSHAP shows relative error above 1.0 at 50 features even with 10,000 samples (Computing Exact Shapley Values in Polynomial Time for Product-Kernel Methods). Beating it means lower attribution error at equal encrypted latency, or equal error at a fraction of the latency, across $d$.

The ablation that isolates our key ingredient is PKeX's Newton-identity recursion ported directly to CKKS with the same kernel approximation. We run it two ways: with a larger parameter set sized for its depth, and with bootstrapping inserted as needed. No reported result was found on Lacuna for encrypted evaluation of Newton's identities. We beat it if we are faster at matched precision and show smaller CKKS-induced error, especially as $d$ grows. A second ablation reduces the quadrature node count, to show how much of our cost is the exactness guarantee.

For accuracy, the ground truth is plaintext PKeX-Shapley, reported to have zero estimation error. For the interventional baseline variant, the ground truth is plaintext RKHS-SHAP, reported to achieve near-perfect $R^2$ against ground-truth Shapley values.

Why not just…?

Why not just run KernelSHAP on the ciphertexts? This is the real threat, because the regression step becomes a plaintext linear map and SIMD packing amortizes coalition evaluations. Its weakness is statistical. Sampling error is already above 1.0 relative error at $d=50$ with 10,000 coalitions in plaintext (Computing Exact Shapley Values in Polynomial Time for Product-Kernel Methods), whereas our method needs only $\lceil d/2\rceil$ product evaluations for exactness. If encrypted KernelSHAP turns out to match our error at comparable latency for small $d$ (say $d\le 10$, as in Breast Cancer or COMPAS), we will report that honestly and restrict our claim to moderate and high dimension. The latency-versus-error curves across $d$ settle the question.

Why not just port PKeX's Newton recursion directly? It is exact in plaintext, but its depth grows with $d$, so bootstrapping repeats. Its alternating-sign sums also amplify CKKS's approximation error. This is precisely the risk the file flags for recursive symmetric-polynomial computation. The Newton ablation in the Baselines measures both the slowdown and the precision loss. If a carefully scaled Newton port stays accurate and within budget at the benchmark dimensions, our contribution shrinks to a constant-factor improvement, and we would say so.

Why not just use two non-colluding servers, as in secure federated Shapley valuation? Secure Shapley Value for Cross-Silo Federated Learning turns ciphertext-ciphertext products into cheaper ciphertext-plaintext ones using secret sharing across two servers, and reports a 7.2× to 36.6× speedup over pure encryption. It values participants rather than features, though, and it depends on a non-collusion assumption that single-provider settings often cannot meet. FHAIM makes the same point about multi-party computation in single-provider settings. Our method reduces the number of ciphertext-ciphertext products to about $\log_2 d$ levels, so the gap such a hybrid could close is smaller. We treat that hybrid as a different threat model, not as a competitor on ours.

Why not just ship the model to the client, or add differential privacy to plaintext explanations? Shipping weights gives away the provider's intellectual property, which is the premise of MLaaS encryption work such as CryptoNets. Differential privacy protects outputs but still requires uploading plaintext records. Neither provides the input confidentiality this setting requires.

Proposed Experiments

On the synthetic product-kernel benchmark with $d$ from 8 to 500, we will plot encrypted latency, consumed levels, bootstrap count and relative attribution error against plaintext PKeX for our method, the Newton port and encrypted KernelSHAP. We expect a crossover past which the Newton port needs bootstrapping while ours does not. Its location, predicted near $d$ in the tens, is a decisive check.

On the real tabular data from the file, we will train RBF-kernel classifiers or regressors and measure several quantities. These are UCI Diabetes; Breast Cancer and COMPAS, as used by FHAIM; and Sonar, Ionosphere and Skillcraft from the PKeX feature-selection suite. The measurements are per-query latency, amortized throughput, ciphertext and key sizes, the efficiency-axiom residual $|\sum_i\phi_i-(f(x)-v(\emptyset))|$ computed after decryption, top-$k$ feature agreement with plaintext attributions, and the prediction-accuracy cost of the kernel approximation.

As a downstream check, we will repeat PKeX's feature-selection protocol using decrypted encrypted attributions. PKeX reports outperforming HSICLasso on 5 of 7 datasets. Recovering that result from encrypted attributions would show the explanations are usable, not merely numerically close.

The proposal fails if any of three things happens: encrypted KernelSHAP matches our error-latency curve at the benchmark dimensions, CKKS error in the kernel approximation dominates attribution error, or the explanation-to-prediction latency ratio exceeds an order of magnitude.