Body signals such as an overnight electrocardiogram (ECG) or a scalp electroencephalogram (EEG) are often scored by a service the patient does not control. One way to keep such a service from seeing the signal is homomorphic encryption: the server computes on encrypted data and returns an encrypted answer that only the patient can read. Existing encrypted neural-network systems were designed for images. They treat each input as an independent sample and pack many samples into one ciphertext. Physiological detectors do not work that way. They slide a window along one long signal and make a decision every few seconds or every minute, and consecutive windows share most of their samples. Packed image by image, the encrypted convolutions are recomputed for every overlapping window, so the server pays for the same samples again and again.
We propose to encrypt the stream instead of the window. Consecutive time samples go into consecutive ciphertext slots. Every convolution layer then runs once over the whole segment, and each window's decision is read off with a cheap encrypted sliding sum. Per-decision server cost should then scale with the step between decisions rather than with the window length. The gain equals the overlap factor: about 5x for apnea scoring, where each 1-minute label uses 5 minutes of context, and about 8x for auditory attention decoding at a 1-second window updated every 0.125 seconds. The same layout also simplifies the hardest part of homomorphic deployment, which is choosing the encryption parameters. Packing turns parameter choice into two separate decisions: the network's multiplicative depth fixes the ring size, and the ring size fixes how much signal fits in one ciphertext.
Core Claim
Sleep apnea detection from single-lead ECG and EEG-based auditory attention decoding (the "cocktail party" problem of telling which talker a listener is attending to) are both overlapping sliding-window problems. For both, a dilated 1D CNN can be evaluated under the CKKS scheme with time laid out along the slots. CKKS is an approximate-arithmetic homomorphic scheme. In this layout, every temporal convolution is a few slot rotations plus multiplications by plaintext weights, and the per-window decision head is a rotate-and-add sliding sum.
Two things would be new. The first is the amortization argument and its measurement. If $W$ is the window length in samples, $S$ the step between decisions, and $R$ the network's receptive field, then the ciphertext work per decision drops from roughly proportional to $W$ to roughly proportional to $S + R/D$, where $D$ is the number of decisions per ciphertext:
$$\frac{\text{cost}_{\text{window-packed}}}{\text{cost}_{\text{stream-packed}}} \approx \frac{W}{S + R/D}.$$
The form follows from slot accounting: window packing fills slots with $W$ samples per decision, while stream packing fills them with $S$ new samples per decision plus a halo of length $R$ shared by the whole ciphertext. The second is a parameter-selection rule specific to streaming time series, explained below.
Apnea is the core application. Overnight recordings are already uploaded for offline scoring, latency is measured in hours, and the encrypted server has a plausible reason to exist. Auditory attention decoding is the stress test. It asks whether the same layout reaches sub-second amortized latency, and we say openly that on-device plaintext inference is a serious competitor in that regime.
Prior Work and Where This Sits
Three lines of encrypted-inference work supply our methods, and all three assume independent static inputs. HTCNN packs many MNIST or CIFAR images into CKKS slots, reuses rotation keys across channels, and splits strided convolutions; it reports 15.6 images/second on MNIST at 98.95% accuracy. We reuse its rotation-reuse ideas, but we pack along time within one signal rather than across samples, which is what removes the redundant computation. FHE-Agent searches CKKS parameters for feedforward vision models with an LLM-guided agent and reports about 3x faster LeNet and LoLA inference than naive configurations. Its cost model knows nothing about window overlap or halo regions, so we use it as a parameter-search baseline. DCT-CryptoNets moves image inference into the frequency domain under the TFHE scheme. Its authors note that the benefit shrinks on small inputs, which is part of why we do not take the frequency-domain route for short 1D windows.
Two papers constrain our design. HE-DL found that a 5-layer square-activation CNN beat a 6-layer one under the BFV scheme, because noise and polynomial degree compound with depth. The CKKS disease classifier saw a sign inversion near zero when it approximated LeakyReLU with a polynomial. Together they push us toward shallow networks with low-degree activations, with normalization done on the client before encryption. That normalization matters because ECG and EEG have baseline drift that can push values outside the range where a polynomial approximation holds.
Nikfam et al. show that spiking networks under BFV take 930 s per sample against 31 s for the equivalent standard network. That result rules out the spiking AAD designs (Corticomorphic CNN-SNN, S²M-Former) as the encrypted model, despite their efficiency in plaintext.
The only encrypted EEG classifier in the file, Liu et al., uses the Paillier scheme. Paillier only adds ciphertexts and multiplies them by plaintexts, so Liu et al. approximate sigmoid with a linear function and cannot run convolutions over ciphertext features. It also targets motor imagery, not attention decoding.
On the application side, the motivating plaintext models are Nguyen et al.'s single-lead apnea detector for apnea, and MHANet and SWIM for attention. Nguyen et al. use 5-minute context blocks, R-peak and S-peak derived sequences, and an SE-ResNeXt-50. MHANet is a 0.02M-parameter network built from dilated multi-scale convolutions. SWIM is a short-window CNN combined with a Mamba state-space model, updating every 0.125 s. MHANet's use of dilated rather than strided convolutions is what makes dense time packing plausible: dilation keeps every output aligned with its slot, while striding scatters outputs across slots.
Research Program
We build one encrypted inference path in CKKS at 128-bit security, following the Homomorphic Encryption Standard bounds on modulus size for each ring dimension. The network family is restricted to operations that keep time dense in the slots:
- dilated 1D convolutions with no stride;
- channel mixing implemented as plaintext-weighted sums of per-channel ciphertexts;
- degree-2 or low-degree polynomial activations;
- a decision head that is a sliding sum over $W$ positions, computed for all positions at once with about $\log_2 W$ rotate-and-add steps, followed by a linear layer.
The client normalizes each segment, encrypts it, uploads it, and decrypts the returned per-decision logits. The server sees only ciphertexts. Segments overlap by the receptive field $R$ so that every decision is valid.
The parameter-selection contribution is a rule plus a measurement. The rule works in four steps. Count the multiplicative depth $L$ of the restricted network. Take the smallest ring dimension $N$ whose modulus budget at 128-bit security supports $L$ levels at the target precision. The ciphertext then holds $N/2$ samples per channel. Finally, check that the wasted halo fraction $R/(N/2)$ is small; if it is not, trade depth for receptive field using dilation.
Rotation keys are needed only for the dilation offsets and for powers of two in the sliding sum, so key memory grows with depth rather than with signal length. We will check whether this rule recovers the configurations a search procedure finds, and at what search cost. Finding that a closed-form rule matches agentic search on this model family would itself be a result about where FHE parameter selection is hard and where it is not.
For apnea, we train a polynomial-activation dilated CNN on PhysioNet Apnea-ECG under per-minute labels with 5-minute context, following Nguyen et al.'s protocol. We train two input variants: the raw band-passed ECG, and the client-side R-peak and S-peak interval sequences that Nguyen et al. found useful. For attention, we train the same family on KUL and DTU at 0.1-, 1- and 2-second windows. We use leave-one-speaker-out splits on KUL following SWIM, because within-trial splits are known to inflate accuracy. We also train an occipital/temporal-only electrode variant, because SWIM found that electrodes near the eyes drive spatial-attention accuracy. Under encryption nobody can audit that shortcut afterwards, so it has to be controlled before deployment.
Baselines
The naive reference point is the HTCNN-style window-packed implementation of exactly the same trained network: each overlapping window is packed as an independent sample and run at identical CKKS parameters. This baseline isolates our key ingredient. Weights, depth, ring dimension and hardware are the same, and only the slot layout differs. Stream packing beats it if measured per-decision server time and upload bytes per hour of signal fall by close to the predicted overlap factor (5x for apnea, 8x for attention at a 0.125 s step) with logits that agree to the same number of bits of precision. We also run both layouts at overlap factor 1, where the theory predicts no gain. If a gain shows up there, it would point to an implementation artifact rather than the mechanism.
The strongest existing accuracy competitors are plaintext. For apnea it is Nguyen et al.'s SE-ResNeXt-50, which reports 91.13% accuracy, 92.58% sensitivity and 88.75% specificity on Apnea-ECG. For attention it is MHANet, which reports 95.6% accuracy at a 0.1 s window on KUL, and SWIM, which reports 86.2% under leave-one-speaker-out on KUL. We retrain each where possible on our exact splits and give our restricted network the same tuning budget. No reported result was found on Lacuna for encrypted apnea detection or encrypted auditory attention decoding, so the honest target is the gap to plaintext. We count the proposal a success on apnea if the encrypted restricted model is within about two points of accuracy of the plaintext SE-ResNeXt. For attention, success means staying within a few points of the plaintext model with matching electrodes and split.
The parameter-search baseline is FHE-Agent run on our network graph with the same compute budget, compared against our closed-form rule on latency, precision bits and search time. A further ablation trains the identical architecture with ReLU and with strided convolutions in plaintext. This separates the accuracy cost of being encryption-friendly from the cost of encryption itself.
Why not just…?
Why not just run the model on the device in plaintext? For attention decoding this is a real threat. MHANet has 0.02M parameters, and the corticomorphic spiking design targets neuromorphic chips, so a hearing aid can plausibly run them locally with no privacy exposure at all. We do not claim encrypted outsourcing beats this for small attention models. We report the server latency and bandwidth at which outsourcing becomes viable, and frame attention decoding as the latency stress test. The case is stronger for apnea: overnight home recordings are scored offline, larger models are useful, and a recording patch has little compute. Even there, the experiment that settles it is whether our encrypted small model matches a model small enough to run on the patch. If it does not beat that model, encryption buys nothing.
Why not just extract features on the client and encrypt a linear model? Nguyen et al. already derive R-peak and S-peak interval sequences before their CNN. A linear or logistic model on such features needs only one or two levels of multiplicative depth under CKKS, and even Paillier, as in Liu et al., could serve it. This is a strong cheap alternative, so we run it: encrypted logistic regression on the interval features against our encrypted CNN on the same features and on raw ECG. If the linear model comes within a point of the CNN, the honest conclusion is that apnea does not need encrypted convolutions. Stream packing would then matter only for raw-signal and EEG models.
Why not just split the network, encrypting the early layers on the server and finishing in plaintext on the client, as HE-DL does? Splitting cuts server time (HE-DL reports about 11.8 s down to about 5.5 s per image). But it sends intermediate features back and forth and still recomputes overlapping windows. Splitting is orthogonal to our layout, so we test it as a combination: stream-packed early layers with a client-side head, measured on the same per-hour bandwidth and latency metrics.
Proposed Experiments
The decisive check is the amortization curve. We plot per-decision server time and memory against overlap factor $W/S$ for stream-packed and window-packed layouts on Apnea-ECG and KUL. The prediction is a flat curve for our layout and a linear one for the baseline, with the gap matching the slot-accounting ratio above. The second check is fidelity: per-minute apnea accuracy, sensitivity and specificity, and attention accuracy at 0.1, 1 and 2 s, comparing decrypted outputs with plaintext outputs of the same network and reporting precision bits of the logits. The third check is the cost of being encryption-friendly: the plaintext gap between our dilated polynomial network and the ReLU and strided versions, and the gap to Nguyen et al., MHANet and SWIM.
The fourth check concerns parameter selection: whether the depth-to-ring-size rule matches FHE-Agent's configurations on this family, and how halo waste and key memory scale with dilation. The fifth checks the eye-gaze confound: we report attention accuracy with frontal and ocular electrodes removed, so that any encrypted attention decoder we claim is decoding auditory attention rather than eye movements. All server timings are measured on one fixed CPU configuration and reported together with ciphertext upload size per hour of signal.
References
- HTCNN: High-Throughput Batch CNN Inference with Homomorphic Encryption for Edge Computing
- FHE-Agent: Automating CKKS Configuration for Practical Encrypted Inference via an LLM-Guided Agentic Framework
- DCT-CryptoNets: Scaling Private Inference in the Frequency Domain
- A Privacy-Preserving Distributed Architecture for Deep-Learning-as-a-Service
- Confidential and Protected Disease Classifier using Fully Homomorphic Encryption
- A Homomorphic Encryption Framework for Privacy-Preserving Spiking Neural Networks
- Corticomorphic Hybrid CNN-SNN Architecture for EEG-Based Low-Footprint Low-Latency Auditory Attention Detection
- S$^2$M-Former: Spiking Symmetric Mixing Branchformer for Brain Auditory Attention Detection
- Classification and Recognition of Encrypted EEG Data Neural Network
- A novel deep learning-based approach for sleep apnea detection using single-lead ECG signals
- MHANet: Multi-scale Hybrid Attention Network for Auditory Attention Detection
- SWIM: Short-Window CNN Integrated With Mamba for EEG-Based Auditory Spatial Attention Decoding
- Homomorphic Encryption Standard