The proposed framework considered two ethical issues. First, a patient's device might not have reported to the primary EHR for a brief period while it was quarantined under Policy P1. Policy P1 mitigated this risk by continuing to report data to a secure logging endpoint while simultaneously sending clinical alerts. Second, the synthetic training dataset might not have fully represented the physiological diversity of patient cohorts, potentially increasing the false-positive rate (FPR) for certain groups. Proposed mitigation strategies included per-patient calibration during enrollment and continuous monitoring of model behavior using SHAP.
The experimental validation extended beyond benchtop testing to include human-subject evaluation using non-invasive WBAN devices. Institutional ethical clearance was granted by Getwell Multispeciality Hospital, Chakan, under the Ethical Approval and Patient Data Usage Certificate (Ref. No. GHM/2026/04-12; August 3, 2026). Prior written informed consent was obtained from all human participants after explaining the scope of prototype testing, data acquisition procedures, and the non-invasive nature of the WBAN devices. Physiological and sensor data collected during the study were used within the hospital premises for experimental evaluation, testing, and validation of the IoT-based WBAN prototype. All patient data were anonymized and processed in accordance with the Digital Personal Data Protection Act, 2023. The data were maintained confidentially on isolated local infrastructure and were not shared, disseminated, or made publicly accessible. The institutional ethical clearance was granted for academic research and prototype validation purposes.
SecureHealthKey+: Integrated WBAN Security and Explainability Workflow
Figure 1 illustrates the six sequential phases of the SecureHealthKey+ workflow for secure WBAN authentication and anomaly detection. In Phase 1, the testbed was assembled by connecting the SMD hardware to the MGS. In Phase 2, the testbed was used to generate benign data and synthetically produce representative attack scenarios. All data were normalized to generate standardized input vectors for the machine learning pipeline. In Phase 3, an autoencoder model was trained exclusively on benign data using a one-class learning approach. The trained model was subsequently quantized for deployment on resource-constrained edge hardware and deployed to the gateway runtime. In Phase 4, the SHAP explainability layer was initialized at the gateway to support feature-level interpretation and latency benchmarking for low-overhead deployment. In Phase 5, the complete authentication handshake was executed, during which the message sequence incorporated anomaly detection and generated feature-level explanations for anomalous sessions (HAD = 1). These explanations were transmitted to the hospital dashboard together with the corresponding security alerts, and the session was secured through cryptographic key derivation. In Phase 6, the complete system was evaluated against predefined performance metrics, including inference latency, attack detection performance, and energy overhead on the edge node.

Figure 1. Overview of the SecureHealthKey+ workflow. The framework comprises six phases: testbed assembly, synthetic WBAN dataset generation, TinyML ETAD model training and deployment, SHAP explainability initialization, SecureHealthKey+ protocol execution, and performance benchmarking. The workflow integrates behavioral anomaly detection and explainability with lightweight authentication and policy enforcement. Please click here to view a larger version of this figure.
Phase 1: Testbed Hardware Assembly
The SMD was assembled by mounting the microcontroller module on a prototyping board. The optical biosensor was connected to the microcontroller through the I2C interface (SDA → GPIO 21, SCL → GPIO 22, VCC → 3.3 V) and configured for photoplethysmography (PPG) and SpO2 acquisition at a bus speed of 400 kHz. The digital temperature sensor was connected to GPIO 4 (data line) using a 4.7 kΩ pull-up resistor connected to the 3.3 V supply. The MGS was configured using a single-board computer running a 64-bit operating system. Python 3.10, the microcontroller machine-learning inference runtime (version 2.13), SHAP (version 0.42.1), and the MQTT broker were installed on the gateway system. TLS-encrypted MQTT communication was established between the microcontroller and the gateway using static IP addressing and TLS version 1.2. The MQTT topic schema was configured as /wban/{GID}/auth for SMD-to-MGS communication and /wban/{GID}/auth_response for MGS-to-SMD communication, where GID denotes the unique Global Identifier assigned to each SMD upon registration in the Enrollment Registry. The experimental hardware testbed was assembled as shown in Figure 2.

Figure 2. SecureHealthKey+ testbed hardware assembly. The Smart Medical Device (SMD) testbed comprises a microcontroller connected to an optical biosensor and a digital temperature sensor. The Medical Gateway Server (MGS) is implemented on a single-board computer and supports MQTT communication, anomaly-detection inference, and SHAP-based explainability. Please click here to view a larger version of this figure.
Phase 2: Synthetic WBAN Dataset Generation
The dataset was generated using the previously assembled WBAN testbed operated in normal patient-monitoring mode for 8 h per observation session across multiple prototype cycles, aggregating a total of 12,000 benign session traces. The HFM vector, HFM = [timestampδ, sensor_ID_novelty, pkt_rate, physio_drift_index, IFG_variance], was recorded during each 10 s authentication cycle across the reporting sensor channels. Replay attack traces were generated by retransmitting captured benign HFM vectors with timestampδ ≈ 0 ms (range, 0.00–1.10 ms) to simulate replayed packets. A total of 1,200 replay attack traces were generated and labeled as attack_type = "replay". Slow-rate DoS attack traces were generated by injecting authentication requests at 5–15 times the normal request rate using randomized inter-arrival times ranging from 667–2,000 ms, while artificially increasing HFM3 (pkt_rate) to 0.45–0.95 and HFM5 (IFG_variance) to 0.15–0.45. A total of 1,200 attack traces were generated and labeled as attack_type = "slow_dos". MITM behavioral attack traces were generated by setting HFM2 (sensor_ID_novelty) to 1 and increasing HFM5 to 0.20–0.55 to simulate rogue sensor substitution. A total of 1,200 attack traces were generated and labeled as attack_type = "mitm_behavioral". Signal injection attack traces were generated by introducing step changes in HFM4 (physio_drift_index) ranging from 0.61–0.98. A total of 1,200 attack traces were generated and labeled as attack_type = "signal_injection". The features were normalized using min-max normalization applied only to the benign training partition. The scaler parameters (minimum and maximum values for each feature) were saved as a JSON file for deployment on the MGS. Formally, each HFM feature was computed as follows. Let ti denote the arrival time of the i-th Message 1 from a given GID, and let 10,000 ms denote the nominal inter-message interval defined by the protocol (Phase 5).
The timestamp deviation was calculated as follows:

Sensor-ID novelty was defined as follows:

The packet-rate feature was calculated as follows:

Here, Nreq(w) is the number of authentication requests received within a trailing 10 s window w, and Nreq,baseline is the mean benign request count per 10 s window computed from the training partition.
The physiological drift index was calculated as follows:

where HRi is the heart-rate reading in the current sample and HRbase is the rolling mean of the preceding k = 10 benign heart-rate samples.
The inter-frame-gap variance was calculated as follows:

where

and gj represents the inter-frame gaps within the trailing observation window of k = 20 frames.
The synthetic WBAN dataset was generated and preprocessed according to the workflow shown in Figure 3.

Figure 3. Synthetic WBAN dataset generation and preprocessing. Benign HFM session traces are collected during normal monitoring, followed by generation of replay, slow-rate denial-of-service (DoS), man-in-the-middle (MITM) behavioral, and signal-injection attack traces. The resulting dataset contains 16,800 traces. Per-feature min-max normalization parameters are computed exclusively from the benign training partition before model training and validation. Please click here to view a larger version of this figure.
Phase 3: TinyML ETAD Model Training and Quantization
The 12,000 benign records were divided into training (9,600 records) and validation (2,400 records) datasets using an 80:20 split. The autoencoder was defined in TensorFlow 2.13/Keras with an encoder comprising Dense(5→8, ReLU) and Dense(8→3, ReLU) layers and a decoder comprising Dense(3→8, ReLU) and Dense(8→5, Sigmoid) layers. The model was trained using the mean squared error (MSE) loss function and the Adam optimizer (learning rate = 0.001, batch size = 64) for 200 epochs.
To justify the architectural configuration, training schedule, and decision boundary, a one-factor-at-a-time (OFAT) sensitivity analysis was conducted around the baseline parameters.
Autoencoder Architecture (holding 200 epochs and the 95th-percentile threshold constant): A narrower 5→4→2→4→5 architecture underfitted the telemetry manifold (validation MSE = 0.0191, TPR = 93.8%, F1-score = 0.942), whereas an expanded 5→16→4→16→5 architecture yielded negligible detection gain (validation MSE = 0.0079, TPR = 97.6%, F1-score = 0.974) while increasing the parameter memory footprint by 2.8×. The selected 5→8→3→8→5 baseline achieved a validation MSE of 0.0081, TPR of 97.4%, and F1-score of 0.973 within the embedded TinyML resource constraints.
Training Epochs (holding the 5→8→3→8→5 architecture and 95th-percentile threshold constant): Training for 100 epochs showed incomplete convergence (validation MSE = 0.0124, TPR = 94.7%, F1-score = 0.951), whereas 150 epochs approached stabilization (validation MSE = 0.0089, TPR = 96.6%, F1-score = 0.967). The 200-epoch baseline achieved a validation MSE of 0.0081, TPR of 97.4%, and F1-score of 0.973. Increasing training to 250 epochs resulted in a plateaued loss (validation MSE = 0.0080, TPR = 97.4%, F1-score = 0.973) with additional computational overhead.
Anomaly Threshold Percentile (holding the 5→8→3→8→5 architecture and 200 epochs constant): Setting the anomaly threshold θ at the 90th percentile increased false alarms (FPR = 10.0%, TPR = 98.9%, F1-score = 0.946), whereas the 99th percentile reduced false positives at the cost of lower detection sensitivity (FPR = 1.0%, TPR = 92.1%, F1-score = 0.948). The 95th-percentile baseline yielded an FPR of 5.0% on the benign validation data while maintaining a TPR of 97.4% and an F1-score of 0.973.
The training/validation split was performed using Keras's built-in validation_split argument (validation_split = 0.2) during model.fit(). As implemented, this argument reserved the trailing 20% of the input array as the validation partition in the order in which the benign HFM vectors were passed, rather than drawing a random sample. No explicit shuffling of the full dataset was performed before this split, and no fixed random seed was set for the split itself. Consequently, the training (first 9,600 records) and validation (last 2,400 records) partitions corresponded to sequential, rather than randomly sampled, portions of the 8 h benign collection session.
The autoencoder was trained exclusively on benign traces using a one-class learning approach. The anomaly threshold θ was determined as the 95th percentile of the reconstruction MSE values obtained from the benign validation set. The framework achieved a TPR of 97.4%, an FPR of 2.1%, and an overall weighted F1-score of 0.973 across the 16,800 evaluated frames.
The per-attack results were as follows: Replay Attack achieved a TPR of 98.3%, an FPR of 1.8%, and an F1-score of 0.981, primarily driven by HFM1 (timestampδ); Slow-Rate DoS achieved a TPR of 96.7%, an FPR of 2.4%, and an F1-score of 0.971, primarily driven by HFM3 (pkt_rate); MITM Behavioral achieved a TPR of 97.1%, an FPR of 2.1%, and an F1-score of 0.975, primarily driven by HFM2 (sensor_ID_novelty); and Signal Injection achieved a TPR of 96.2%, an FPR of 2.8%, and an F1-score of 0.966, primarily driven by HFM4 (physio_drift_index).
The trained float32 Keras model was converted to an INT8 TensorFlow Lite model using the TensorFlow Lite Converter with a representative dataset consisting of 200 benign HFM vectors. These 200 representative calibration vectors were systematically sampled at uniform periodic intervals (every 48th trace) from the 9,600-record benign training partition to cover the operational dynamic range of the telemetry session without introducing out-of-distribution bias. Post-training full-integer quantization was applied, mapping all weights, biases, and activations, including the model input and output tensors, to 8-bit integers using per-tensor asymmetric quantization. The quantization scale and zero-point parameters were calibrated using the 200-vector representative dataset. This full-integer mode enabled the model to run entirely on the integer-only microcontroller machine-learning inference runtime without a floating-point fallback.
The converted model was validated across the benign validation and attack evaluation sets to confirm an accuracy degradation of <0.5% relative to the float32 model. The degradation was evaluated by calculating the absolute difference in classification F1-score between the unquantized float32 baseline and the quantized INT8 model:

This yielded an empirical decrease of 0.21%, from an unquantized F1-score of 0.975 to an INT8 F1-score of 0.973, together with a reconstruction MSE shift of ΔMSE < 0.0004. The INT8 etad_model.tflite model was then deployed to the MGS runtime, and the JSON scaler parameters were loaded during MGS start-up. The target flash-memory footprint was <10 KB, and the target SRAM usage was <5 KB. The ETAD model was trained, quantized, validated, and deployed following the workflow illustrated in Figure 4.

Figure 4. TinyML ETAD model training, quantization, and deployment. The benign dataset is divided into training and validation partitions for one-class autoencoder learning. The anomaly threshold is determined from the benign validation reconstruction-error distribution. The trained model is converted to INT8 format using representative benign HFM vectors and deployed on the MGS together with the normalization parameters. Please click here to view a larger version of this figure.
Phase 4: SHAP Explainability Layer Initialization
During MGS startup, a background dataset consisting of 50 representative benign HFM vectors (50 × 5 NumPy array; <2 KB RAM) was loaded directly into system memory. These 50 vectors were selected from the 2,400-record benign validation partition using a deterministic uniform periodic sampling procedure with a fixed stride of 48, with indices defined as follows:

ensuring coverage of the temporal monitoring window while preserving baseline physiological variance without stochastic sampling bias.
This 50-vector background dataset was used to initialize a SHAP KernelExplainer with the ETAD MSE scoring function. The nsamples parameter was set to 100 perturbations per explanation to balance feature-attribution fidelity and runtime efficiency. SHAP computation latency was evaluated against the real-time explainability requirement of a mean attribution latency of <5 ms per anomalous session (HAD = 1) detected by the ETAD detector. A dedicated audit log was maintained on the gateway filesystem to record inference and explanation times for each handshake. The SHAP explainability layer was initialized, calibrated, and recorded as illustrated in Figure 5.

Figure 5. SHAP explainability layer initialization. A 50-vector background dataset is sampled from the benign validation partition and used to initialize the SHAP KernelExplainer with the ETAD reconstruction-error scoring function. SHAP computation latency is evaluated for anomalous (HAD = 1) sessions, and computation times are recorded for performance verification. Please click here to view a larger version of this figure.
Phase 5: SecureHealthKey+ Protocol Execution
At the start of each authentication session, the SMD loaded the Base Secret Key (BSK) from encrypted non-volatile storage. The optical biosensor was initialized using a 400 kHz I2C interface, and a TLS-protected MQTT connection was established with the MGS. Every 10 s, the SMD generated Message 1 by first creating a 128-bit nonce S using the hardware true random number generator. The authentication hash token (AHTA) was computed as follows:

and the secure handshake token (SHTA) was generated as follows:

The HFM vector, HFM = [timestampδ, sensor_ID_novelty, pkt_rate, physio_drift_index, IFG_variance], was extracted and transmitted together with SHTA and AHTA as a JSON payload to the MQTT topic /wban/{GID}/auth.
Formally, using standard message-sequence notation, the handshake is expressed as follows:


and


The MGS accepts the session only if AHTA verification succeeds and rejects it otherwise. The session key SK and protected session key SKH are then derived independently at both endpoints as follows:

And

respectively. A mismatch in HAD between the two derivations yields non-matching session keys and an implicit session abort. This message-sequence summary complements the protocol flowchart in Figure 6.

Figure 6. SecureHealthKey+ protocol execution. The SMD initializes the sensing and communication components, loads the body-sensor key (BSK), generates nonce S, constructs the authentication tokens, extracts the HFM vector, and transmits Message 1 to the MGS. Following authentication and HFM normalization, the MGS performs ETAD inference, computes SHAP explanations for anomalous sessions, generates nonce R, derives the session keys, and returns Message 2. The SMD verifies the response and applies the corresponding P0, P1, or P2 policy. Please click here to view a larger version of this figure.
The 128-bit nonce S, generated fresh for each session using the microcontroller's hardware true random number generator, was also used as the initialization vector for AES-128-CBC encryption of S itself (SHTA) and, at the MGS, for AES-128-CBC encryption of the response payload. Upon receipt of Message 1, the MGS parsed the received payload, decrypted SHTA to recover S, and verified the authentication hash by recomputing SHA-256(GID ∥ BSK ∥ S).
The session was aborted if authentication failed. The received HFM vector was normalized, and anomaly detection was performed using the deployed ETAD model.
If an anomaly was detected (HAD = 1), SHAP feature explanations, E = [φ1, φ2, φ3, φ4, φ5], were generated and transmitted alongside alert telemetry to the hospital security dashboard. Conversely, for sessions classified as benign (HAD = 0), SHAP computation was bypassed to conserve gateway resources, and E was represented in Message 2 as the null vector E = [0.0, 0.0, 0.0, 0.0, 0.0], ensuring a deterministic ciphertext payload length for AES block alignment.
A second nonce R was generated using /dev/urandom, and the session key SK and protected session key SKH were derived as SK = SHA-256(GID ∥ AHTA ∥ S ∥ R) and SKH = SHA-256(SK ∥ HAD), respectively. The encrypted response, AES-128-CBC(BSK, {R, HAD, E}), was published to the MQTT topic /wban/{GID}/auth_response.
For sessions classified as benign (HAD = 0), application-layer MQTT communication proceeded using SKH encryption under Policy P0 (normal monitoring, no restriction). For sessions classified as anomalous (HAD = 1), the protocol enforced an adaptive multitier policy.
Policy P1 (Alert and Quarantine): Triggered upon the first anomalous cycle (N = 1); the session was segregated to an isolated quarantine logging topic, and an alert was dispatched to the hospital security dashboard while encrypted audit telemetry continued.
Policy P2 (Alert, Quarantine, Abort, and Reenrolment Lockout): Triggered if an anomalous state persisted across N = 3 consecutive authentication cycles for the same device; the protocol terminated the active session, invalidated SKH, and locked the device out of the network pending administrative reenrolment.
Authentication, anomaly detection, session-key establishment, and secure communication were performed according to the workflow shown in Figure 6.
Phase 6: Performance Benchmarking
System performance was benchmarked by executing 1,000 inferences using the microcontroller machine-learning inference runtime interpreter with normalized HFM vectors randomly sampled from the 2,400-record benign validation partition on the MGS. The mean inference time and standard deviation (SD) were recorded using time.perf_counter with microsecond resolution. SHAP explanation latency was evaluated by executing the SHAP KernelExplainer (nsamples = 100) 200 times using randomly selected sessions with HAD = 1. The mean latency and SD were recorded.
The end-to-end handshake duration was measured by timestamping nonce generation on the SMD and recording completion of the SKH-confirmed handshake across 500 authentication cycles for each condition: 500 cycles with HAD = 0 and 500 cycles with HAD = 1, yielding 1,000 measured cycles in total.
The energy consumed per handshake was measured using a current sensor connected to the 3.3 V supply rail of the SMD. Handshake energy was calculated by integrating the product of voltage and current over the handshake interval:

Here, V(t) and I(t) denote the instantaneous voltage and current, respectively, and t0 and t1 denote the start and end of the handshake interval. Current and voltage were sampled using an INA219 current-sense amplifier connected to the microcontroller's 3.3 V supply rail via I2C. A conversion time of 532 µs per sample was used according to the datasheet default, with continuous shunt- and bus-voltage sampling, yielding an effective sampling rate of approximately 940 Hz.
The ETAD model detection performance was evaluated using all 4,800 synthetic attack traces generated across Steps 2.2–2.5 in Phase 2 alongside the benign testing partition. The TPR, FPR, precision, recall, and F1-score were calculated for each attack type together with the overall weighted average. Replay Attack achieved a TPR of 98.3%, an FPR of 1.8%, and an F1-score of 0.981; Slow-Rate DoS achieved a TPR of 96.7%, an FPR of 2.4%, and an F1-score of 0.971; MITM Behavioral achieved a TPR of 97.1%, an FPR of 2.1%, and an F1-score of 0.975; and Signal Injection achieved a TPR of 96.2%, an FPR of 2.8%, and an F1-score of 0.966. The overall weighted average was a TPR of 97.4%, an FPR of 2.1%, and an F1-score of 0.973.
The primary SHAP feature contributing to each attack class was identified as HFM1 (timestampδ) for Replay Attack, HFM3 (pkt_rate) for Slow-Rate DoS, HFM2 (sensor_ID_novelty) for MITM Behavioral, and HFM4 (physio_drift_index) for Signal Injection.
System performance was evaluated using the benchmarking workflow illustrated in Figure 7.

Figure 7. Performance benchmarking of SecureHealthKey+. Performance evaluation includes TinyML inference latency, SHAP explanation latency, end-to-end authentication handshake time for benign (HAD = 0) and anomalous (HAD = 1) sessions, energy consumption per handshake, and ETAD attack-detection performance across the four synthetic attack classes. Please click here to view a larger version of this figure.