This repository integrates Defensive ML techniques into Maya.
Most of the framework remain the same, except that we replace Maya's Gaussian Sinusoid planner with a Defensive ML defender.
You can do either of followings:
- Use the pre-trained defender to protect the system from power
- Train a new defender by collecting the power traces from your system
- Install PARSEC 3.0 benchmark and modify PARSECDIR in Scripts/Launch.sh, line 184.
- Follow instructions of Maya-README.md to set up the Maya framework in your system.
- Install PyTorch. Running the ML-related code requires a CUDA-capable GPU.
- Install libtorch API and set TORCHDIR in Makefile to the directory where libtorch is installed.
makewill build the system.
- Running
./defender_wrapper.sh 0 [samplecount]will turn on the Maya defense with Defensive ML, and collect the PARSEC benchmark traces while the defense is active. Recommended samplecount: 100 (total 1000 traces for 10 benchmarks). It will take 5~6 hours to collect 1000 traces. - Running
python MayaDataset.py --victimdir defender_logswill emulate the attack on the power side-channel, giving the CNN accuracy.
- Run
./wrapper.sh 0 [samplecount]to collect unprotected traces for PARSEC benchmark runs. Recommended samplecount: 400 (total 4000 traces). It will take a full day to collect 4000 traces. - Run
python DefensiveML.pyto train the ML defender. - Change name of the output pth file
cp parsec_shaper_64_[...].pth best_shaper_64.pth - Follow shaperToScript.ipynb to get the jit-traced cpuscript_parsec_shaper_64.pt. Copy it under Controller/ directory.
cp cpuscript_parsec_shaper_64.pt Controller/ssvFast3_Shaper_64.pt
Or, you can use the providedController/ssvFast3_Shaper_64.pt - Run
./defender_wrapper.sh 0 [samplecount]to collect the traces with the defender activated. - Run
./maya_wrapper.sh 0 [samplecount]to collect the traces with Maya defense activated. - Run
MayaDataset.py --victimdir [defender_logs|maya_logs]to evaluate the defense results for ML defense (defender_logs) or Maya defense (maya_logs)