Anatomy-Hiding Electric Field Simulation in Confidential Cloud Enclaves

Brain stimulation with weak scalp currents works better when the dose is planned on a simulation of the patient's own head. The same 2 mA produces very different fields inside different skulls, and the field reaching the cortex, not the current at the scalp, is what tracks clinical response. Building that simulation means turning a full-head MRI into a 3D mesh and solving a large sparse electrical problem. Clinics usually lack the compute and the engineers to do this, so they would like to send the job to a cloud. The scan they would send contains the face, and for many patients it also contains a lesion that reveals the diagnosis. Hardware enclaves are processor-protected regions where data stays encrypted outside the chip. They could make such outsourcing acceptable. But an enclave still lets the host machine watch which memory pages the program touches. For a mesh-based solver, that pattern of touches is shaped by the patient's anatomy.

This note proposes a simulation pipeline whose memory behaviour is identical for every patient. The idea is to keep one public template mesh and change only its numbers. The cloud host always sees the same mesh layout, the same matrix shape and the same number of solver steps. Patient-specific anatomy enters only through node coordinates and tissue conductivities, and these values are read in a fixed order. We will show two things: that standard pipelines run in an enclave leak recoverable anatomy through their access pattern, and that the fixed-structure pipeline removes this leak while staying close to fully individualized models in field accuracy.

Core Claim

Modern confidential virtual machines can already run an unmodified simulator such as SimNIBS or ROAST with full memory encryption. The tools are mentioned in this file only as the modelling packages used in the clinical cohorts of Cerebro-cerebellar functional neuroplasticity mediates the effect of electric field on electroconvulsive therapy outcomes and Combined behavioral and electrophysiological evidence for a direct cortical effect of prefrontal tDCS on disorders of consciousness. Encrypting memory is therefore not the hard part. The hard part is that every data-dependent stage of the standard pipeline exposes structure to the host:

  • tetrahedral meshing produces a patient-specific number of elements and a patient-specific connectivity;
  • the setup of algebraic multigrid (the standard fast solver for these systems, reported 1.8 to 3.5 times faster than plain iterative solvers in Review on solving the forward problem in EEG source analysis) coarsens according to matrix values;
  • the conjugate-gradient iteration count reflects how ill-conditioned the patient's conductivity field is.

Our claim is that a fixed-topology formulation makes all of these observable quantities independent of the patient by construction, at a field-accuracy cost small enough not to matter clinically. Concretely, if $S$ is the public sparsity pattern of the template stiffness matrix, $x$ the patient's warped node coordinates, $\sigma$ the patient's per-element conductivities, and $T$ the fixed iteration budget, the host observes a trace

$$\tau = g(S, T),$$

which contains no $x$ and no $\sigma$. Leakage then reduces to timing variation in floating-point arithmetic, which we measure rather than assume away.

This is a different design point from the closest prior work. An Algorithmic Framework For Differentially Private Data Analysis on Trusted Processors. showed that enclave access patterns leak records, and it made histogram and distinct-count queries oblivious using sketches small enough to stay in registers. We make a physics solver oblivious by fixing its structure rather than by adding noise or shuffling memory. PRESAGE protected genomic lookups with fixed 4 KB blocks, but its workload is hash lookups over one-dimensional records, not sparse solves over 3D meshes.

Research Program

The leak. We first establish that the leak is real. We run SimNIBS unmodified inside a confidential VM and record page-granular access traces from the host's vantage point. These traces include page-fault sequences, the mesh and matrix sizes implied by allocations, and iteration counts. Using public Cam-CAN scans, where ground truth is known, we train an attacker model to predict anatomy from the traces. Its targets are head size, regional skull thickness, the regional CSF volumes that Variation of cerebrospinal fluid in specific regions regulates focality in transcranial direct current stimulation found to govern focality, and the presence and location of synthetic lesions inserted into the scans. If this attacker performs at chance, the rest of the program loses its motivation, and we will report that outcome as the result.

The fixed-structure pipeline. The pipeline has four stages:

  1. Segmentation. A dense convolutional network segments tissues. Its memory access over a fixed voxel grid does not depend on the data.
  2. Registration. The New York Head template (The New York Head - A precise standardized volume conductor model for EEG source localization and tES targeting) is warped to the patient by a dense deformable registration on the same fixed grid. This template has 0.5 mm resolution, six tissue types, and a neck included, a field of view that paper showed matters for accurate fields.
  3. Assembly. Each template element receives a conductivity from the tissue labels at its warped location. Lesions, craniotomies and atrophy become changes in element values, not changes in mesh topology.
  4. Solve. The system is solved with a multigrid hierarchy built once on the public template and reused for every patient, followed by a fixed number $T$ of preconditioned conjugate-gradient steps. $T$ is chosen offline so that the worst-case residual over a calibration cohort meets tolerance.

All branches on tissue labels are replaced by arithmetic selection. The enclave's remote attestation, a signed hash of the code it is running, is extended so that the report also commits to a hash of the input scan and to summary statistics of the output field. This gives the clinic a verifiable record of which code produced which dose, in the spirit of Proof-of-Guardrail in AI Agents and What (Not) to Trust from It, applied here to dosimetry rather than to text moderation. Attestation is a secondary deliverable. The core contribution is the oblivious pipeline.

Accuracy and cost analysis. We characterize where fixed topology fails. The expected failure is near thin structures and sharp lesion boundaries, where a fixed mesh cannot add elements, and we quantify how template resolution trades accuracy against cost.

Baselines

Naive reference: template only. The patient's dose is computed on the unwarped New York Head and mapped to the patient. This setting leaks nothing. Its accuracy cost is the floor any individualized method must beat. The file reports that incongruent models lose localization accuracy: median EEG source localization error was 10.3 mm for ICBM-NY against 13.3 mm for an incongruent FEM (The New York Head - A precise standardized volume conductor model for EEG source localization and tES targeting). That number is for EEG source localization, not tES. For tES the same paper reports only that ICBM-NY outperformed alternatives on field-intensity error and peak mismatch, with no single number listed.

Accuracy ceiling and leakage worst case: unmodified SimNIBS with patient-specific meshing. This is run inside a confidential VM on the same hardware with default settings. Individualized models of this kind are what produced the clinical correlations in the ECT and disorders-of-consciousness cohorts. This baseline is both the reference for accuracy and the worst case for leakage.

Strongest privacy competitor: generic oblivious execution. The unmodified solver's sparse matrix-vector products and multigrid setup are wrapped in oblivious memory access, padded to a public maximum mesh size. It is the textbook way to remove access-pattern leaks without redesigning the algorithm. No reported result for oblivious sparse PDE solvers was found on Lacuna, so we implement it ourselves on the same hardware with the same tolerance.

Ablations. The first keeps fixed topology but restores data-dependent multigrid setup and run-to-tolerance iteration counts. This isolates whether the template-built hierarchy and the fixed iteration budget are necessary. The second keeps the oblivious pipeline but leaves branchy label assignment in place.

What counts as beating the competitors. The fixed-structure pipeline beats the oblivious-execution baseline if it reaches attacker performance indistinguishable from chance at lower wall-clock cost. It beats template-only if it recovers most of the gap to unmodified SimNIBS in target field error. All methods use the same scans, the same hardware, and the same convergence tolerance on the unmodified baseline.

Why not just…?

Why not just run SimNIBS in a confidential VM and stop there? This is the main threat to the proposal, and it is our baseline. Memory limits that constrained first-generation enclaves, discussed in Goten and DarkneTZ, largely do not apply to confidential VMs. So partitioning the solver to fit a small enclave, the obvious "memory wall" project, is not worth doing. What confidential VMs do not remove is page-level visibility to the host. The leakage experiment decides whether that visibility matters for head anatomy. If the attacker cannot beat chance on lesion location or regional CSF, we will say the simpler approach suffices.

Why not just wrap the existing solver in generic oblivious memory? It works in principle. However, it charges a per-access overhead on every matrix entry, in every iteration, of a system with millions of unknowns. It also still requires padding to a worst-case mesh size. We run it head-to-head, so its cost is measured rather than asserted.

Why not just de-face the scan, or use fully homomorphic encryption? De-facing removes the face but leaves the lesion, which is the sensitive diagnostic content. It also truncates the scalp and neck boundary that the New York Head work found important for accurate fields. Fully homomorphic encryption was about 120 times slower than an enclave even for simple genomic lookups in PRESAGE. An iterative 3D solve is a far heavier workload, so we do not expect it to be competitive and treat it only as a cited reference point.

Why not just use the template and skip the patient? Template-only is our naive baseline. Two findings argue against it. Stroke motor hotspots sat on average 18.5 mm from standard M1 in Effects of high-definition tDCS targeting individual motor hotspot with EMG-driven robotic hand training on upper extremity motor function: a pilot randomized controlled trial. Regional CSF changes focality, which a template cannot capture. The accuracy experiment measures how much of this the warped template recovers.

Proposed Experiments

Leakage. On roughly 300 Cam-CAN heads, matching the cohort size in the CSF focality study, with synthetic lesions inserted into a subset, we train attackers on the host-visible traces of each pipeline. We report:

  • lesion detection AUC;
  • lesion localization error in mm;
  • regression error for regional skull thickness and CSF volume.

We use held-out subjects throughout, and we include residual timing traces for the fixed-structure pipeline.

Accuracy. For the F3-RSO and CP5-Cz montages from the CSF study, we compare each pipeline against unmodified SimNIBS on:

  • relative error in target E-field magnitude;
  • peak-location mismatch in mm;
  • 90th-percentile brain field, the summary used in the ECT study;
  • agreement in focal versus non-focal classification under that study's Dose-Target-Determination-Index threshold of 0.75.

Where access permits, we repeat the comparison on lesioned clinical scans.

Cost. We report end-to-end wall-clock time and cloud cost per patient against the roughly $1,500 per-patient modelling cost cited in the stroke trial. We also report attestation latency overhead against the 25 to 38 percent reported for enclave guardrails.

Decisive outcome. The proposal succeeds if three conditions hold together: the unmodified pipeline leaks lesion location well above chance, the fixed-structure pipeline brings that leak to chance, and the fixed-structure pipeline keeps focality classifications in agreement with individualized modelling for most subjects. If any of the three fails, the paper reports which one, and that is itself useful guidance for clinics choosing among cloud options.