AI-powered hardware Trojan detection · side-channel power analysis
Catch the Trojan by the power it draws.
A hardware Trojan can pass every functional test, but it cannot hide the extra current it pulls when its payload runs. RAQIB measures an ESP32-S3's supply current through a single 1 Ω shunt, digitises it with a 24-bit ADS1256 on a Raspberry Pi 4, and separates normal from Trojan behaviour with unsupervised clustering — no golden chip, no labelled Trojan data.
Built for one question
Can a low-cost rig tell Trojan activity from normal operation using power consumption alone, without a trusted reference chip or labelled Trojan data? Every part of RAQIB exists to answer that.
Firmware-emulated Trojan
The ESP32-S3 runs a Trojan with a hidden trigger (a button press) and a payload that heats the chip with extra square-root computation: 30,000 operations per cycle in the Dormant state (33–37 °C) and 50,000 in the Active state (38–45 °C). A cooling routine drops the clock to 160 MHz until the chip is back at 29 °C.
Unsupervised clustering
The detector never sees a label. It compares k-means, a Gaussian mixture model and Ward clustering for k = 2–4 and keeps the model with the highest silhouette score. The recorded states are used only afterwards, to score how well the clusters match.
Physically meaningful features
Six power-level features (mean, RMS, energy, 10th percentile, median, 90th percentile) separated Normal from Trojan perfectly, while the full 19-feature set reached an ARI of only 0.17. Fewer features with a clear physical meaning beat a larger generic set.
Low-cost measurement chain
A single 1 Ω high-side shunt (1 mV per mA), an ADS1256 at 30,000 samples per second with a gain of 64, and a Raspberry Pi 4 reading it over SPI — in place of a benchtop oscilloscope and laboratory supply.
Local and reproducible
Everything runs on the Raspberry Pi or a laptop with no cloud service. A fixed random seed means the same recording always gives the same result.
Live device monitor
No device connectedConnect the Raspberry Pi to stream the supply current measured through the shunt, or plug the ESP32-S3 in over USB to follow its state and temperature.
Waiting for a device…
Raspberry Pi: run python3 live_server.py next to the acquisition program, then open the site from the Pi at
http://raspberrypi.local:8000 (or open it as a local file) and press Connect Raspberry Pi.
ESP32-S3: needs Chrome or Edge on a computer; the board's serial output (115200 baud) is read directly.
The live indicator is a simple threshold against a Normal baseline you set; the verdicts reported in the Results come from the offline clustering pipeline.
From a button press to a verdict
Trigger
A push button on the ESP32-S3 switches between Normal, Dormant and Active. A status LED shows the state, and FreeRTOS tasks share the internal temperature sensor through a semaphore.
Payload
Once triggered, the payload runs extra square-root computation until the chip reaches its target temperature, drawing measurably more current than normal operation.
Measure
The supply current crosses a 1 Ω high-side shunt. The ADS1256 reads AIN0−AIN1 differentially at gain 64, and the Pi 4 logs every sample to CSV over SPI.
Detect
The trace is cut into 250-sample windows (step 50). Features are standardised, reduced with PCA (95% variance) and clustered; the silhouette score chooses the model and number of clusters.
What the recording showed
One continuous recording of 105,654 samples: Normal (9,806), Trojan (92,886) and Cooling (2,962). The Trojan nearly doubled the supply current and added frequent short spikes.
| Task | Features | Silhouette | Balanced acc. | ARI |
|---|---|---|---|---|
| Normal vs Trojan | Power-level (6) | 0.90 | 100% | 1.00 |
| Normal vs Trojan | Full set (19) | 0.48 | 85.3% | 0.17 |
| Three states | Power-level (6) | 0.90 | 66.7% | 0.85 |
| Three states | Full set (19) | 0.52 | 65.9% | 0.30 |
All 192 Normal windows and all 1,907 Trojan-affected windows were assigned correctly. The 55 Cooling windows join the Trojan cluster, so the after-effect is still flagged as abnormal.
Limitations: one recording in a fixed order, one strong payload, and relative rather than absolute current values. Repeated randomised recordings and weaker payloads are the next step.
The prototype
Everything sits on one breadboard and was built in four tested stages: ADC to Pi, the shunt, the ESP32-S3 with its buttons and LEDs, and a common ground.
- Raspberry Pi 4 (4 GB)SPI0, CE0, 3.84 MHz, DRDY on GPIO25
- ADS1256 ADCAIN0−AIN1, PGA 64, 30,000 SPS
- ESP32-S3 N16R8Device under test, 3.3 V through the shunt
- 1 Ω shunt resistorHigh-side, 1 mV per mA
- Breadboard power module3.3 V supply for the ESP32-S3
- 3 push buttons + LEDsGPIO1 / GPIO2 / GPIO38, LEDs on GPIO48 / 47 / 21
Built by
Batool Sayed Jaffar
Computer Engineering
Eman Rabeea Abdulla
Computer Engineering
Walaa Abdulla Alsabbagh
Computer Engineering
Academic supervision
RAQIB was developed as an ITCE 499 senior project in the Department of Computer Engineering, College of Information Technology, University of Bahrain (Academic Year 2026–2027, Semester 1).
Get in touch
Questions about the measurement rig, the firmware Trojan or the clustering pipeline — reach out to the team.